/// <summary> /// 异步卸载场景。 /// </summary> /// <param name="sceneAssetName">要卸载场景资源的名称。</param> /// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param> /// <param name="userData">用户自定义数据。</param> public void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData) { if (string.IsNullOrEmpty(sceneAssetName)) { Log.Error("Scene asset name is invalid."); return; } if (unloadSceneCallbacks == null) { Log.Error("Unload scene callbacks is invalid."); return; } #if UNITY_5_5_OR_NEWER AsyncOperation asyncOperation = SceneManager.UnloadSceneAsync(sceneAssetName); if (asyncOperation == null) { return; } m_UnloadSceneInfos.AddLast(new UnloadSceneInfo(asyncOperation, sceneAssetName, unloadSceneCallbacks, userData)); #else if (SceneManager.UnloadScene(SceneComponent.GetSceneName(sceneAssetName))) { if (unloadSceneCallbacks.UnloadSceneSuccessCallback != null) { unloadSceneCallbacks.UnloadSceneSuccessCallback(sceneAssetName, userData); } } else { if (unloadSceneCallbacks.UnloadSceneFailureCallback != null) { unloadSceneCallbacks.UnloadSceneFailureCallback(sceneAssetName, userData); } } #endif }