Ejemplo n.º 1
0
    /// <summary>
    /// 设置状态
    /// </summary>
    /// <param name="LoadSceneName"></param>
    /// <param name="isLoadScene"></param>
    public void SetState(string LoadSceneName, bool isLoadScene = false)
    {
        m_bRunBegin = false;
        //如果上一次的状态还存在 则先释放
        if (m_State != null)
        {
            m_State.StateEnd();
        }
        //先保存一下要切换到那个场景
        m_NextSceneName = LoadSceneName;
        //判断是否要进行加载过渡
        if (isLoadScene)
        {
            LoadScene(m_LoadSceneName);
            m_State = FindState(m_LoadSceneName);
            if (m_State != null)
            {
                m_State.LoadTransitionScene(m_NextSceneName);
            }
        }
        else
        {
            LoadScene(m_NextSceneName);
            m_State = FindState(m_NextSceneName);
        }

        if (m_State == null)
        {
            Debug.LogError("切换状态失败");
        }
    }