I saw that a new function was added with Unity 2.1, Application.LoadLevelAdditive.
I have a few questions about this function.
1: My project current uses an Awake function along with DontDestroyOnLoad to keep objects from being destroyed when new levels are loaded. Is there any benefit to switching this over to Application.LoadLevelAdditive? Generally speaking I don’t want to destroy any of my objects when I load a new level in this particular project.
2: I thought I’d try it out but I ran into a problem where the function OnLevelWasLoaded is not called after Application.LoadLevelAdditive is complete. Is there some other function I can use to determine whether or not Application.LoadLevelAdditive has completed loading the level? I also tried using Application.loadedLevelName in the Update function to give me the name of the most recently loaded level but that did not appear to work either.
yes, loadleveladditive won’t require you to add the dontdestroyonload to all your objects. It’ll always keep all old items, and you’ll never forget to keep one. There won’t be much other differences.
The three methods suggested above do not seem to be working to me. I have to do some initialization of objects just when I’m sure a certain level has been completely loaded by Application.LoadLevelAdditive, but Application.loadedLevel gives me only the index of my starting level abd Application.isLoadingLevel returns false accordingly.
Has anyone found an answer in the meantime? Thanks.
load level additive adds the corresponding level to the current one.
As such the current level is still the same as before etc.
What you likely will do is have an array or better hashtable where you store all levels in that you have loaded.
main drawback of using loadleveladditive as a replacement of don’t destroy is that the memory requirements rise. nothing is ever cleaned unless you do it manually …
Sorry if this is a bit off-topic, but is there any plan to add a “RemoveLevelSubtractive” function?
Seriously, though. I’m working on a scenario where I have a player flying a ship through space, and they approach a planet. I’d like to have the player transition from space to atmospheric flight, and it occurs me that LoadLevelAdditive is a good way to do that (remove space environment effects, fade in atmospherics and terrain, then world objects. However, without some straightforward way to remove previous levels from the game, I’d have to manually track all of my “space” components and remove them, right?