private void Update() { if (!((LockPauseModule.GetPauseLockState() ?? PauseLockType.AllowCutscene) > PauseLockType.AllowMenu)) //handle pauses { return; } if (LockPauseModule.GetInputLockState() == InputLockType.All) { return; } //this probably won't work, but it's supposed to reselect after a return from the menu if (EventSystem.currentSelectedGameObject == null || !EventSystem.currentSelectedGameObject.activeInHierarchy) { SelectButton(SelectedButton); } //update our view of SelectedButton if (EventSystem.currentSelectedGameObject != CurrentButtons[SelectedButton].gameObject) { int newIndex = CurrentButtons.IndexOf(EventSystem.currentSelectedGameObject.GetComponent <Button>()); if (newIndex >= 0) { SelectedButton = newIndex; } //Debug.Log($"selected {SelectedButton}"); } }
private void CheckMenuOpen() { if (LockPauseModule.GetInputLockState() == InputLockType.All) { return; } bool menuToggled = UnityEngine.Input.GetKeyDown(KeyCode.Escape) || MappedInput.GetButtonDown(Input.DefaultControls.OpenMenu); if (menuToggled) { //if we're locked out, let the menu be closed but not opened if (!AllowMenu) { if (IsOpen) { Close(); } } else { //otherwise, flip state Toggle(); } } }
private void CheckMenuOpen() { if (LockPauseModule.GetInputLockState() == InputLockType.All) { return; } bool menuToggled = UnityEngine.Input.GetKeyDown(KeyCode.Escape) || MappedInput.GetButtonDown(Input.DefaultControls.OpenMenu); if (menuToggled) { //if we're locked out, let the menu be closed but not opened if (!AllowMenu) { if (MainPanel.activeSelf) { MainPanel.SetActive(false); if (HandlePause) { DoUnpause(); } foreach (Transform child in ContainerPanel.transform) { child.gameObject.SetActive(false); } ClearEphemeral(); } } else { //otherwise, flip state bool newState = !MainPanel.activeSelf; MainPanel.SetActive(newState); if (HandlePause) { if (newState) { DoPause(); } else { DoUnpause(); } } if (newState && !string.IsNullOrEmpty(DefaultPanel)) { OnClickSelectButton(DefaultPanel); } if (!newState) { foreach (Transform child in ContainerPanel.transform) { child.gameObject.SetActive(false); } ClearEphemeral(); } if (newState) { //run scripts ScriptingModule.CallHooked(ScriptHook.OnIGUIMenuOpen, this); } } } }