LoadLevelAsync seems to not working for me properly...
public void GoToScene(string scene)
{
StartCoroutine("InitializeMainScene", scene);
}
public IEnumerator InitializeMainScene(string scene)
{
yield return null;
AsyncOperation load = Application.LoadLevelAsync("mainScene");
//load.allowSceneActivation = false;
while (!load.isDone)
{
Debug.Log("Progress: " + load.progress);
yield return null;
}
manager.ChangeScene(scene);
}
Here is the code. GoToScene is called after clicking a button. I want the main level to be fully loaded before I start changing scenes. For that reason I used LoadLevelAsync with the expectation that "manager.ChangeScene" is executed only after loading finishes.
What happens instead is that the code after while operation never gets executed. With allowSceneActivation commented out, the level is loaded normally. If I uncomment the line, no level loading ever takes place. Is there something I'm missing here?
↧