// Update is called per one frame void Update() { if( nextState == null ) { if( currentState != gameState ) currentState.Update(); } else { if( currentState != null ) currentState.beforeChanging(); currentState = nextState; nextState = null; currentState.afterChanged(); } }