Example #1
0
    //设置当前的状态
    public void ChangeState(BaseSceneState state)
    {
        currentState.StateEnd();                                              //执行上一状态的end方法

        currentState = state;                                                 //切换状态

        asyncOperation = SceneManager.LoadSceneAsync(currentState.SceneName); //异步加载当前场景
        isRunStart     = false;                                               //异步执行当前状态的Start方法
    }
    public void SetState(BaseSceneState _state, string loadSceneName)
    {
        //载入场景
        isLoad   = true;
        runBegin = false;
        LoadScene(loadSceneName);

        //通知前一个State结束
        if (m_State != null)
        {
            m_State.StateEnd();
        }

        //设置新的状态
        m_State = _state;
    }