Esempio n. 1
0
    public void SetState(ISceneState state, bool isLoadScene = true)
    {
        if (state == null)
        {
            return;
        }

        if (mState != null)
        {
            mState.Exit();
        }

        mState = state;

        if (isLoadScene)
        {
            // 异步加载场景
            mAO = SceneManager.LoadSceneAsync(mState.SceneName);

            mIsRunEnter = false;
        }
        else
        {
            //本身就在这个场景就无需加载场景了,例如: StartScene
            mState.Enter();

            mIsRunEnter = true;

            mAO = null;
        }
    }
    public void StateUpdate()
    {
        if (isLoading)
        {
            return;
        }

        if (state != null && isRunEnter == false)
        {
            state.Enter();
            isRunEnter = true;
        }

        if (state != null)
        {
            state.Update();
        }
    }
Esempio n. 3
0
    public void UpdateState()
    {
        if (mState == null)
        {
            return;
        }

        // 新场景需要异步加载完成
        if (mAO != null && !mAO.isDone)
        {
            return;
        }

        if (mAO != null && mAO.isDone && !mIsRunEnter)
        {
            mState.Enter();

            mIsRunEnter = true;

            mAO = null;
        }

        mState.UpdateState();
    }