Beispiel #1
0
        // 卸载战场
        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();
        }
Beispiel #2
0
        // 卸载战场
        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();
        }