Unity3D

Unity 简单的异步加载场景

2017-03-06  本文已影响968人  U3D界金城武
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();

上一篇 下一篇

猜你喜欢

热点阅读