【发布时间】:2016-10-13 07:15:15
【问题描述】:
我正在创建一个针对 Samsung Gear VR 的 Unity 应用程序。我目前有两个场景:
- 初始场景
- 第二个场景,数据量大(加载场景时间太长)。
从第一个场景开始,我想在后台加载第二个场景,并在加载后切换到它。在后台加载新场景时,用户应保持移动头部以查看 VR 环境的任何部分的能力。
我正在使用SceneManager.LoadSceneAsync,但它不起作用:
// ...
StartCoroutiune(loadScene());
// ...
IEnumerator loadScene(){
AsyncOperation async = SceneManager.LoadAsyncScene("Scene", LoadSceneMode.Single);
async.allowSceneActivation = false;
while(async.progress < 0.9f){
progressText.text = async.progress+"";
}
while(!async.isDone){
yield return null;
}
async.allowSceneActivation = true;
}
使用该代码,场景永远不会改变。
我已经尝试了典型的SceneManager.LoadScene("name"),在这种情况下,场景会在 30 秒后正确更改。
【问题讨论】: