/// <summary> /// 将临时入栈的state出栈, 并设置成当前状态 /// </summary> public void PopStackState() { GameStateBase oldState = currentState; if (oldState != null) { oldState.PrepareExit(); } currentState = stateStack.Pop(); currentState.PreparePopStack(); if (oldState != null) { var oldStateType = oldState.StateType; oldState.Exit(); // 记录上次的状态 stateChangingContex.RecordLastState(oldStateType); } currentState.PopStack(); if (oldState != null) { oldState.DoneExit(); oldState.Dispose(); GameObject.Destroy(oldState); } currentState.DonePopStack(); }