Loading new scene in background

ⅰ亾dé卋堺 提交于 2019-12-05 12:28:18

This should work

    while(async.progress < 0.9f){
          progressText.text = async.progress.ToString();
          yield return null;
    }

Secondly, I've seen cases where isDone is never set to true, unless the scene has activated. Remove these lines:

    while(!async.isDone){
          yield return null;
    }

On top of that, you are locking your code in that first while loop. Add a yield so the application can continue loading your code.

So your entire code looks like this:

IEnumerator loadScene(){
    AsyncOperation async = SceneManager.LoadAsyncScene("Scene", LoadSceneMode.Single);
    async.allowSceneActivation = false;
    while(async.progress <= 0.89f){
          progressText.text = async.progress.ToString();
          yield return null;
    }
    async.allowSceneActivation = true;
}

The biggest culprit to your problem is the locking in the first while loop, though.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!