/* Pop the top-most state, making sure it is previousState. */ public void PopState(UiState previousState) { if (stateStack.Count == 0) { throw new Exception("Cannot call PopState when no states are currently visible"); } if (stateStack.Last() != previousState) { throw new Exception("PopState called but top-most state has unexpected value: " + previousState.GetType()); } stateStack.RemoveAt(stateStack.Count - 1); previousState.Hide(); }