/// <summary> /// Standard pause menu: Locked and invisible cursor, uses existing time scale, unpaused game. /// </summary> public static MenuAttributes StandardInGame() { MenuAttributes attributes = new MenuAttributes(); attributes.cursorLockMode = CursorLockMode.Locked; attributes.cursorVisible = false; attributes.timeScale = -1f; attributes.pauseGame = false; return(attributes); }
/// <summary> /// Standard non-pause menu: Confined and visible cursor, uses existing time scale, unpaused game. /// </summary> public static MenuAttributes StandardNonPauseMenu() { MenuAttributes attributes = new MenuAttributes(); attributes.cursorLockMode = CursorLockMode.Confined; attributes.cursorVisible = true; attributes.timeScale = -1f; attributes.pauseGame = false; return(attributes); }
void CacheCurrentMenuAttributes() { MenuAttributes attributes = new MenuAttributes(); attributes.cursorLockMode = Cursor.lockState; attributes.cursorVisible = Cursor.visible; attributes.timeScale = Time.timeScale; attributes.pauseGame = _paused; _cachedMenuAttributes.Push(attributes); }
void PopAndApplyMenuAttributes() { if (_cachedMenuAttributes.Count == 0) { Debug.LogWarning("Attempting to pop menu attributes but stack is empty!"); return; } MenuAttributes attributes = _cachedMenuAttributes.Pop(); ApplyMenuAttributes(attributes); }
public MenuAttributes GetMenuAttributes() { MenuAttributes attributes = new MenuAttributes { cursorLockMode = CursorLockMode, cursorVisible = CursorVisible, pauseGame = PausesGame, timeScale = TimeScale }; return(attributes); }
public MenuConfig(bool toggleable, bool startsOpen, bool menuPausesGame, string mainPanelKey, PaletteConfig paletteConfig, PanelConfig[] panelConfigs, List <System.Action <string, string> > panelChangeCallbacks = null, MenuAttributes?menuAttributesOverride = null) { Toggleable = toggleable; StartsOpen = startsOpen; MenuPausesGame = menuPausesGame; MainPanelKey = mainPanelKey; PaletteConfig = paletteConfig; PanelConfigs = panelConfigs; MenuAttributes = menuAttributesOverride.HasValue ? menuAttributesOverride.Value : (menuPausesGame ? MenuAttributes.StandardPauseMenu() : MenuAttributes.StandardNonPauseMenu()); PanelChangeCallbacks = panelChangeCallbacks ?? new List <System.Action <string, string> >(); }
void ApplyMenuAttributes(MenuAttributes attributes) { if (!DisableCursorManagement) { Cursor.lockState = attributes.cursorLockMode; Cursor.visible = attributes.cursorVisible; } if (!DisableTimeManagement && attributes.timeScale >= 0) { Time.timeScale = attributes.timeScale; } UpdatePaused(attributes.pauseGame); }