private bool CheckComboEvent(KeyCombo keyCombo, KeyEventType keyEventType = KeyEventType.Down) { if (keyCombo.ModKey1 != KeyCode.None && !CommonInput.GetKey(keyCombo.ModKey1)) { return(false); } if (keyCombo.ModKey2 != KeyCode.None && !CommonInput.GetKey(keyCombo.ModKey2)) { return(false); } switch (keyEventType) { case KeyEventType.Down: return(CommonInput.GetKeyDown(keyCombo.MainKey)); case KeyEventType.Up: return(CommonInput.GetKeyUp(keyCombo.MainKey)); case KeyEventType.Hold: return(CommonInput.GetKey(keyCombo.MainKey)); default: return(CommonInput.GetKeyDown(keyCombo.MainKey)); } }
void CheckKeyboardInput() { if (!UIManager.IsInputFocus && GameData.IsInGame && CustomNetworkManager.Instance.IsClientConnected()) { // Perform escape key action // TODO make stack system more general so each target can define its own close function (probs using unity editor and events?) if (CommonInput.GetKeyDown(KeyCode.Escape)) { if (EscapeKeyTarget.TargetStack.Count > 0) { GUI_IngameMenu.Instance.CloseMenuPanel(EscapeKeyTarget.TargetStack.Peek()); } else { GUI_IngameMenu.Instance.OpenMenuPanel(GUI_IngameMenu.Instance.mainIngameMenu); } } // Perform the checks for all key actions which have functions defined here foreach (KeyValuePair <KeyAction, DualKeyCombo> entry in keybindManager.userKeybinds) { if (!keyActionFunctions.ContainsKey(entry.Key)) { continue; } if (CheckComboEvent(entry.Value.PrimaryCombo) || CheckComboEvent(entry.Value.SecondaryCombo)) { // Call the function associated with the KeyAction enum keyActionFunctions[entry.Key](); } } } }
void CheckKeyboardInput() { if (!UIManager.IsInputFocus && GameData.IsInGame && CustomNetworkManager.Instance.IsClientConnected()) { // Perform escape key action if (CommonInput.GetKeyDown(KeyCode.Escape)) { EscapeKeyTarget.HandleEscapeKey(); } // Perform the checks for all key actions which have functions defined here foreach (KeyValuePair <KeyAction, DualKeyCombo> entry in keybindManager.userKeybinds) { if (!keyActionFunctions.ContainsKey(entry.Key)) { continue; } if (CheckComboEvent(entry.Value.PrimaryCombo) || CheckComboEvent(entry.Value.SecondaryCombo)) { // Call the function associated with the KeyAction enum keyActionFunctions[entry.Key](); } } } }
private void Update() { if (CommonInput.GetKeyDown(KeyCode.F6) && !BuildPreferences.isForRelease) { GameData.IsLoggedIn = true; ShowCharacterEditor(); } }
public KeyCombo CaptureKeyCombo() { KeyCode newKey = KeyCode.None; KeyCode newModKey1 = KeyCode.None; KeyCode newModKey2 = KeyCode.None; // Iterate through all possible keys foreach (KeyCode key in System.Enum.GetValues(typeof(KeyCode))) { if (ModKeys.Contains(key) || IgnoreKeys.Contains(key)) { // If it's a modifier/ignored key we can skip it for now continue; } else if (CommonInput.GetKeyDown(key)) { // Stop capturing if user presses escape if (key == KeyCode.Escape) { return(null); } // Keep the key for later so we can return it newKey = key; // Check if any modifiers are pressed too foreach (KeyCode modKey in ModKeys) { if (!CommonInput.GetKey(modKey)) { continue; } // A modifier key is pressed, assign it to the first available modkey if (newModKey1 == KeyCode.None) { // ModKey1 hasn't been assigned yet newModKey1 = validateModKey(modKey); if (newModKey1 == KeyCode.AltGr) { // Since AltGr is a strange key which sends AltGr, LeftControl and RightAlt at the same time // we will only allow it to be a modifier key on its own, so we can stop checking now break; } } else if (newModKey2 == KeyCode.None) { // ModKey2 hasn't been assigned yet // Assign it then stop checking since all modkeys assigned newModKey2 = validateModKey(modKey); break; } } } } // Return the new key combination return(new KeyCombo(newKey, newModKey1, newModKey2)); }
void UpdateMe() { if (CommonInput.GetKeyDown(KeyCode.Tab)) { if (thisField.isFocused) { nextField.ActivateInputField(); } } }
/// <summary> /// Check if escape has been pressed /// </summary> public static bool IsEscapePressed() { if (CommonInput.GetKeyDown(KeyCode.Escape)) { return(true); } else { return(false); } }
/// <summary> /// Check if enter (the return or numpad enter keys) has been pressed /// </summary> public static bool IsEnterPressed() { if (CommonInput.GetKeyDown(KeyCode.Return) || CommonInput.GetKeyDown(KeyCode.KeypadEnter)) { return(true); } else { return(false); } }
/// <summary> /// If snapToBottom is enabled, force the scrollbar to the bottom /// </summary> private void LateUpdate() { Debug.developerConsoleVisible = false; //makes the default unity console disappear, rather hacky but unity doesnt give us a way to properly disable it if (screenDimensionsChanged) { // Update the recycled list view if (isLogWindowVisible) { recycledListView.OnViewportDimensionsChanged(); } else { popupManager.OnViewportDimensionsChanged(); } screenDimensionsChanged = false; } if (snapToBottom) { logItemsScrollRect.verticalNormalizedPosition = 0f; if (snapToBottomButton.activeSelf) { snapToBottomButton.SetActive(false); } } else { float scrollPos = logItemsScrollRect.verticalNormalizedPosition; if (snapToBottomButton.activeSelf != (scrollPos > 1E-6f && scrollPos < 0.9999f)) { snapToBottomButton.SetActive(!snapToBottomButton.activeSelf); } } // Hide/Show the debugger windows when user presses F5 if (CommonInput.GetKeyDown(KeyCode.F5)) { if (popupManager.isLogPopupVisible || isLogWindowVisible) { Hide(); // popupManager.Hide(); } else { // popupManager.ShowWithoutReset(); Show(); } } }
/// <summary> /// If snapToBottom is enabled, force the scrollbar to the bottom /// </summary> private void LateUpdate() { if (screenDimensionsChanged) { // Update the recycled list view if (isLogWindowVisible) { recycledListView.OnViewportDimensionsChanged(); } else { popupManager.OnViewportDimensionsChanged(); } screenDimensionsChanged = false; } if (snapToBottom) { logItemsScrollRect.verticalNormalizedPosition = 0f; if (snapToBottomButton.activeSelf) { snapToBottomButton.SetActive(false); } } else { float scrollPos = logItemsScrollRect.verticalNormalizedPosition; if (snapToBottomButton.activeSelf != (scrollPos > 1E-6f && scrollPos < 0.9999f)) { snapToBottomButton.SetActive(!snapToBottomButton.activeSelf); } } // Hide/Show the debugger windows when user presses F5 if (CommonInput.GetKeyDown(KeyCode.F5)) { if (popupManager.isLogPopupVisible || isLogWindowVisible) { Hide(); popupManager.Hide(); } else { popupManager.ShowWithoutReset(); } } }
void CheckKeyboardInput() { if (!UIManager.IsInputFocus) { // Perform escape key action if (CommonInput.GetKeyDown(KeyCode.Escape)) { EscapeKeyTarget.HandleEscapeKey(); } // Only check for keyboard input once in-game if (GameData.IsInGame && Mirror.NetworkClient.active) { CheckInGameKeybinds(); } } }
void CheckKeyboardInput() { if (!UIManager.IsInputFocus) { // Perform escape key action if (CommonInput.GetKeyDown(KeyCode.Escape)) { EscapeKeyTarget.HandleEscapeKey(); } // Only check for keyboard input once in-game if (GameData.IsInGame && CustomNetworkManager.Instance.IsClientConnected()) { CheckInGameKeybinds(); } } }
void CheckKeyboardInput() { if (!UIManager.IsInputFocus && GameData.IsInGame && CustomNetworkManager.Instance.IsClientConnected()) { // Perform escape key action if (CommonInput.GetKeyDown(KeyCode.Escape)) { if (EscapeKeyTarget.TargetStack.Count > 0) { EscapeKeyTarget escapeKeyTarget = EscapeKeyTarget.TargetStack.Peek().GetComponent <EscapeKeyTarget>(); escapeKeyTarget.OnEscapeKey.Invoke(); if (escapeKeyTarget.DisableOnEscape) { GUI_IngameMenu.Instance.CloseMenuPanel(EscapeKeyTarget.TargetStack.Peek()); } } else { GUI_IngameMenu.Instance.OpenMenuPanel(GUI_IngameMenu.Instance.mainIngameMenu); } } // Perform the checks for all key actions which have functions defined here foreach (KeyValuePair <KeyAction, DualKeyCombo> entry in keybindManager.userKeybinds) { if (!keyActionFunctions.ContainsKey(entry.Key)) { continue; } if (CheckComboEvent(entry.Value.PrimaryCombo) || CheckComboEvent(entry.Value.SecondaryCombo)) { // Call the function associated with the KeyAction enum keyActionFunctions[entry.Key](); } } } }
/// <summary> /// Check if escape has been pressed /// </summary> public static bool IsEscapePressed() { return(CommonInput.GetKeyDown(KeyCode.Escape)); }
/// <summary> /// Check if enter (the return or numpad enter keys) has been pressed /// </summary> public static bool IsEnterPressed() { return(CommonInput.GetKeyDown(KeyCode.Return) || CommonInput.GetKeyDown(KeyCode.KeypadEnter)); }