LoadLevelAsync stuck in standalone occasionally
Hi All,
Like many others, I try to use LoadLevelAsync() to create a loading screen while loading the next level in our game. But then I run into this weird behavior. The loading works fine in the editor but not in the standalone build. In the standalone build, the progress would stuck at ~90% and never finish. But if you tab out the game and switch back to the game, the loading will be finished.
Here is my load coroutine:
public IEnumerator LoadLevelHandler(int levelId)
{
yield return null;
AsyncOperation async = Application.LoadLevelAsync(levelId);
float showPortion = 0.0f;
while (async.progress < 1.0f)
{
if (constantLoop)
{
SetLoadingImageFill(showPortion += Time.unscaledDeltaTime);
if (showPortion > 1.0f)
showPortion = 0.0f;
yield return null;
}
else
{
SetLoadingImageFill(async.progress);
yield return null;
}
}
yield return async;
}
Any idea on what happened?
Does the behaviour change if you ins$$anonymous$$d of while (async.progress < 1.0f)
change to while (!async.isDone)
?
Perhaps there's a glitch where progress won't be set to 1, but the operation is done.
Your title says it happens occasionally and mention both editor and standalone.
Do you mean it happens occasionally when in standalone, or always when in standalone?
I've tried to use async.isDone, the problem persists.
It's occasionally happening in standalone only. In editor it works fine.