Ejemplo n.º 1
0
    public override void UpdateState()
    {
        if (_loadingOp.isDone && !_isLoadFinish)
        {
            _isLoadFinish = true;
            string sceneName = string.Empty;
            sceneName = GameStateHelper.SetSceneName(GameStateManager.Instance.NextState);
            _nextOp   = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);

            sceneName = GameStateHelper.SetSceneName(GameStateManager.Instance.PreviousState);
            _prevOp   = SceneManager.UnloadSceneAsync(sceneName);
        }

        if (_nextOp != null && _prevOp != null && _isLoadFinish && !_isUnloadFinish)
        {
            if (_prevOp.isDone && _nextOp.isDone)
            {
                _loadingOp      = SceneManager.UnloadSceneAsync("Loading");
                _isUnloadFinish = true;
            }
        }

        if (_loadingOp.isDone && _isLoadFinish && _isUnloadFinish)
        {
            GameStateManager.Instance.ChangeState(GameStateManager.Instance.NextState);
        }
    }