/// <summary> /// 卸载战场 /// </summary> /// <param name="onDone"></param> /// <returns></returns> IEnumerator <float> _UnLoadBattle(Callback onDone) { //暂停一段时间 SelfBaseGlobal.PauseGame(true); yield return(Timing.WaitForSeconds(0.1f)); Callback_OnBattleUnLoad?.Invoke(); yield return(Timing.WaitForSeconds(1.0f)); string sceneName = CurData.GetSceneName(); var wait = SceneManager.UnloadSceneAsync(sceneName); while (!wait.isDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress); } //卸载未使用的资源 SelfBaseGlobal.DLCMgr.UnloadAsset(SceneAsset); SelfBaseGlobal.DLCMgr.UnLoadBattleAssetBundle(); CurData.OnBeRemoved(); CurData = null; Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); BaseGlobalMonoMgr.RemoveAllNull(); GC.Collect(); yield return(Timing.WaitForSeconds(0.1f)); Callback_OnBattleUnLoaded?.Invoke(); SelfBaseGlobal.ResumeGame(); onDone?.Invoke(); }
/// <summary> /// 移除行为树 /// </summary> protected override void RemoveBT() { if (CurData != null) { CurData.OnBeRemoved(); } CurData = null; }
/// <summary> /// 移除 /// </summary> protected virtual void Remove() { if (CurData != null) { CurData.OnBeRemoved(); } CurData = null; }
/// <summary> /// 停止一段剧情 /// </summary> public virtual void Stop() { if (CurData == null) { return; } CurData.OnBeRemoved(); CurData = null; }
// 卸载战场 IEnumerator <float> _UnLoadBattle(Callback onDone) { if (CurData == null) { yield break; } IsLoadingBattle = false; IsLoadBattleEnd = false; IsGameStart = false; CurData.OnBeRemoved(); CurData = null; yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoad?.Invoke(); yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f); //延时一秒.防止UI卡住 yield return(Timing.WaitForSeconds(0.3f)); var wait = SceneManager.UnloadSceneAsync(SceneName); while (!wait.isDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress); } //卸载未使用的资源 GRMgr.UnloadScene(SceneAsset); Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); BaseGlobal.ResumeGame(); yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoaded?.Invoke(); onDone?.Invoke(); }
// 卸载战场 IEnumerator <float> _unLoadBattle(Callback onDone) { IsLoadedScene = false; IsLoadingBattle = false; IsLoadBattleEnd = false; IsGameStartOver = false; IsInPauseLoadingView = false; CurData.OnBeRemoved(); CurData = null; //暂停一段时间 BaseGlobal.PauseGame(true); BaseInputMgr.ResetFullScreenState(); Callback_OnBattleUnLoad?.Invoke(); yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("Start to load", 0.01f); //延时一秒.防止UI卡住 yield return(Timing.WaitForSeconds(0.5f)); var wait = SceneManager.UnloadSceneAsync(SceneName); while (!wait.isDone) { yield return(Timing.WaitForOneFrame); Callback_OnLoadingProgressChanged?.Invoke("UnloadScene", wait.progress); } //卸载未使用的资源 GRMgr.UnloadScene(SceneAsset); Callback_OnLoadingProgressChanged?.Invoke("GC", 1.0f); yield return(Timing.WaitForOneFrame); Callback_OnBattleUnLoaded?.Invoke(); BaseGlobal.ResumeGame(); onDone?.Invoke(); }