/// <summary> /// 异步加载Unity场景 /// </summary> /// <param name="name"></param> /// <param name="finishHander"></param> public void LoadUnitySceneAsyncLua(string name, int mode, OnUnitySceneLoadDelegate handler) { AsyncOperation ao = SceneManager.LoadSceneAsync(name, (LoadSceneMode)mode); ao.completed += delegate(AsyncOperation asp) { if (handler != null) { handler(asp.progress, asp.isDone); } }; }
/// <summary> /// 异步加载Unity场景 /// </summary> /// <param name="name"></param> /// <param name="finishHander"></param> public void LoadUnitySceneAsync(string name, LoadSceneMode mode, string lastScene, bool cleanLast, OnUnitySceneLoadDelegate handler) { Action <AsyncOperation> curD = delegate(AsyncOperation asp) { if (handler != null) { handler(asp.progress, asp.isDone); } }; // if (cleanLast) { AsyncOperation last = SceneManager.UnloadSceneAsync(lastScene); if (last != null) { last.completed += delegate(AsyncOperation asp) { if (asp.isDone) { AsyncOperation ao = SceneManager.LoadSceneAsync(name, mode); ao.completed += curD; } }; } else { AsyncOperation ao = SceneManager.LoadSceneAsync(name, mode); ao.completed += curD; } } else { AsyncOperation ao = SceneManager.LoadSceneAsync(name, mode); ao.completed += curD; } }