Hi forums!
I’m trying to get Application.LoadLevelAsync working, but I’m running into some strange things. This is happening in 4.6, on a build.
If I set allowSceneActivation to false, the async.progress gets stuck at .9f forever, and async.isDone is never true. So this code gets stuck in the while(!async.isDone) loop forever:
AsyncOperation async;
public string levelName;
public IEnumerator LoadThing() {
yield return StartCoroutine(Load());
//Fades the screen out, works fine.
yield return StartCoroutine(FadeOut());
async.allowSceneActivation = true;
}
IEnumerator Load() {
async = Application.LoadLevelAsync(levelName);
async.allowSceneActivation = false;
text.text = "Async called, waiting for progress";
while (!async.isDone) {
//Will log "Progress: 90%" forever
Debug.Log("Progress: " + (async.progress * 100) + "%");
yield return null;
}
}
If I don’t set allowSceneActivation to false, the scene loads. That’s not really helpfull, as that doesn’t give me an async load.
The kicker is that this makes everything work nicely:
while (async.progress < .9f) {
Debug.Log("Progress: " + (async.progress * 100) + "%");
yield return null;
}
But it seems really hacky.
Am I using LoadLevelAsync wrong? To me, it looks like it’s hardcoded in that the async operation can’t be set to done or progress further than .9 unless it’s allowed to activate the scene. Which kinda defeats the purpose of the whole thing.