Esempio n. 1
0
    IEnumerator DoActionLoadScene(string _nameScene)
    {
        bool _isFinished = false;

        Show(false, () => {
            _isFinished = true;
        });
        yield return(new WaitUntil(() => _isFinished));

        yield return(Yielders.EndOfFrame);

        DateTime _timeStart = DateTime.UtcNow;

        CoroutineChain.StopAll();
        LeanTween.cancelAll(true);
        CoreGameManager.instance.ClearAllCallbackPressBackKey();
        PopupManager.Instance.UnActiveAllPopups();
        LoadingCanvasController.instance.Hide();
        GetGoldScreenController.instance.ForcedHide();
        SettingScreenController.instance.ForcedHide();
        ChooseSubGameScreenController.instance.ForcedHide();
        MyAudioManager.instance.StopAll();

        CoreGameManager.instance.currentSceneManager = null;

        // AudioManager.PauseMusic ();
        // AudioManager.instance.isStopPlayingNewSound = true;

        var asyncLoad = SceneManager.LoadSceneAsync(_nameScene, LoadSceneMode.Single);

        yield return(new WaitUntil(() => asyncLoad.isDone));

        if (myCanvas.worldCamera == null)
        {
            myCanvas.worldCamera = Camera.main;
        }

        yield return(Resources.UnloadUnusedAssets());

        yield return(new WaitUntil(() => CoreGameManager.instance.currentSceneManager != null && CoreGameManager.instance.currentSceneManager.canShowScene));

        long _timeLoadScene = (long)(DateTime.UtcNow - _timeStart).TotalMilliseconds;

        while (_timeLoadScene < 1000)
        {
            yield return(null);

            _timeLoadScene = (long)(DateTime.UtcNow - _timeStart).TotalMilliseconds;
        }

        // AudioManager.instance.isStopPlayingNewSound = false;
        Hide(false);

        yield break;
    }
 private void Update()
 {
     if (Input.GetKeyUp(KeyCode.A))
     {
         chain.RunCoroutine();
     }
     if (Input.GetKeyUp(KeyCode.D))
     {
         CoroutineChain.StopAll();
     }
 }