/// <summary> /// Pops a hidden menu out of the stack, and /// changes the last menu already in the stack to visible /// </summary> internal IMenu PopFromManagedStack() { // Make sure this menu is already on top of the stack IMenu returnMenu = null; if (NumManagedMenus > 0) { // If so, pop the menu returnMenu = managedMenusStack.Pop(); // Check if there are any other menus left if (NumManagedMenus > 0) { // Change the top-most menu into visible managedMenusStack.Peek().CurrentVisibility = IMenu.VisibilityState.Visible; } else { // Lock the cursor to what the scene is set to SceneChanger.RevertCursorLockMode(); } // Unselect the highlighted item Events.SetSelectedGameObject(null); // Run the event that indicates the stack changed OnManagedMenusStackChanged?.Invoke(this); } return(returnMenu); }
/// <summary> /// Pushes a visible menu into the stack, and /// changes the other menus already in the stack to stand-by /// </summary> internal void PushToManagedStack(IMenu menu) { if (menu != null) { // Make sure the menu isn't already in the stack // (the stack is usually small, so this should be pretty efficient) if (managedMenusStack.Contains(menu) == false) { // Change the top-most menu (if any) to stand-by if (NumManagedMenus > 0) { managedMenusStack.Peek().CurrentVisibility = IMenu.VisibilityState.StandBy; } else { // Unlock the cursor SceneTransitionManager.CursorMode = CursorLockMode.None; } // Push the current menu onto the stack managedMenusStack.Push(menu); // Unselect the highlighted item Events.SetSelectedGameObject(null); // Run the event that indicates the stack changed OnManagedMenusStackChanged?.Invoke(this); } } }