美文网首页Unity3D
Unity 简单的异步加载场景

Unity 简单的异步加载场景

作者: U3D界金城武 | 来源:发表于2017-03-06 11:34 被阅读968次
AsyncOperation async;   //定义异步加载

 void Start () {
        StartCoroutine(SceneLoad());
    }

  IEnumerator SceneLoad()
    {
        async = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex + 1);//下一个加载场景
        async.allowSceneActivation = false;//场景暂时不进入
        yield return async;
    }
//激活场景
 public void ActivatedScene()
    {
        async.allowSceneActivation = true;
    }

//需要加载的时候
   GetComponent<sceneCG>().ActivatedScene();

相关文章

网友评论

    本文标题:Unity 简单的异步加载场景

    本文链接:https://www.haomeiwen.com/subject/lugygttx.html