public IEnumerator ChangeStateCoroutine(MenuStates gameState) { m_changingState = true; //get old state MenuState currentState = GetState(m_menuState); //get new state MenuState newState = GetState(gameState); Debug.Log("States Fetched"); //transittion from old state yield return(StartCoroutine(currentState.OnExit())); Debug.Log("Exited state"); //transittion into new state yield return(StartCoroutine(newState.OnEnter())); Debug.Log("entered state"); m_menuState = gameState; m_changingState = false; yield return(null); }