Unity 简单的异步加载场景

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().ActivatedScene();

你可能感兴趣的:(Unity 简单的异步加载场景)