Well, I know it’s not Unity- because I moved some things around and now things aren’t working as expected.
Thing is, the stuff I moved around was all outside my async level loading coroutine and not really relevant to it.
The problem is that the scene is loading immediately instead of halting. The code is originally Alan Zucconi’s (thanks Alan) but I do understand what every line should mean.
Mmmm, thanks. I think I was interrupting something. I might have to get back to this thread. I was trying to load through to a loading scene, and provide it a target scene to load each time.
So I had this here, and it would start with a state machine change… But I was just loading a level before doing it; I think the previous load was not complete, breaking things.
Sorry to revive an old post. But I’m having the same problem.
I created a scene with just a background and a loading bar.
The idea was that when wanting to load scenes I would load this scene loading scene and it would load the desired scene.
The problem is that apparently the allowSceneActivation flag is ignored if you have recently loaded the scene, you need to wait a bit of time. Which is really odd.
I hope someone at unity sees this and takes a look.
for some reason , If you start SceneManager.LoadSceneAsync in Awake func or SceneManager.sceneLoaded callback
func, the allowSceneActivation won’t work.
the solution is start a coroutine and insert yield return new WaitForSeconds(0.1f);
before loadsceneasync
something like
IEnumerator CoSceneLoading(string sceneName)
{
yield return new WaitForSeconds(0.1f);
var asynOp = SceneManager.LoadSceneAsync(sceneName);
asynOp.allowSceneActivation = false;
//do your work
}