public void ChangeState(GameStateNames stateName) { //-- if not first time then exit the current state if (m_CurrentState != GameStateNames.NONE) { //-- allow the state to unload m_StateMap[m_CurrentState].StateExit(); //-- disable the states gameobject m_StateMap[m_CurrentState].gameObject.SetActive(false); } //-- enable the new states gameobject m_StateMap[stateName].gameObject.SetActive(true); //-- call it the new states init function m_StateMap[stateName].StateEntry(); //-- cache the new current state m_CurrentState = stateName; }
public void ChangeState( GameStateNames stateName ) { //-- if not first time then exit the current state if( m_CurrentState != GameStateNames.NONE ) { //-- allow the state to unload m_StateMap[m_CurrentState].StateExit(); //-- disable the states gameobject m_StateMap[m_CurrentState].gameObject.SetActive( false ); } //-- enable the new states gameobject m_StateMap[stateName].gameObject.SetActive( true ); //-- call it the new states init function m_StateMap[stateName].StateEntry(); //-- cache the new current state m_CurrentState = stateName; }