I’m attempting to know the best way to make use of Application.LoadLevelAdditiveAsync. I would like to load a new scene, but not have it be visible until I “flip a switch”. I thought perhaps setting asyncOperation.allowSceneActivation would do the trick, however, the documentation doesn’t really tell me how to use this. How do I know when the scene is loaded but not activated? The best I can tell from my own experimentation is that the asyncOperation.progress will be 0.9? Even so, how do I then activate the scene.
I separately tried making the root node of my loaded scene inactive in the editor. This almost worked, as I can see the inactive nodes being added in the scene. But then since .Find() doesn’t work on inactive nodes I don’t know how to grab them and activate them.
I just started tinkering with AsyncOperation.allowSceneActivation as well, and I think I got one step further, but have similar findings.
As best as I can tell, the appropriate way to make use of it is with the following steps:
Begin the AsyncOperation. (i.e. AsyncOperation async = Application.LoadLevelAdditiveAsync)
set AsyncOperation.allowSceneActivation to false
Wait until the asyncOperation’s progress is 0.9 or larger. AsyncOperation.isDone won’t be set to true until the asyncOperation completes including activation.
set AsyncOperation.allowSceneActivation to true
yield on the AsyncOperation or wait until AsyncOperation.isDone is true
It would be good to get a confirmation that these are the appropriate steps. Either way, waiting until progress is >= 0.9 seems like an arbitrary and also undocumented process. I’d much rather have a flag that specifically says when non-activation loading is completed… or even better, an alternate means of yielding until AsyncOperation.allowSceneActivation is ready to be toggled back.
After struggling for a while with allowSceneActivation, the ‘wait for >=0.9’ thing seems to work for me too. My current scene loads appear to stop at exactly 0.9 when allowSceneActivation is false.
It does seem a very ugly solution, though. Is it actually safe to do this? - Is there really no cleaner option?