/// <summary> /// FSM 有限状态机初始化 /// </summary> private void MakeFSM() { fsmSystem = new FSMSystem(); FSMState[] fsmStates = this.GetComponentsInChildren <FSMState>(); foreach (FSMState state in fsmStates) { fsmSystem.AddState(state, this); } MenuState menuState = this.GetComponentInChildren <MenuState>(); if (menuState != null) { fsmSystem.SetDefaultState(menuState); } else { Debug.Log("没有找到 MenuState 组件,请确认..."); } }