public static new bool GetKeyDown(KeyCode keyCode) { if (!Enabled) { return(false); } if (consumedKeys.Contains(keyCode)) { return(false); } #if UNITY_EDITOR if (IsOnWindows) { if (keysPressed.Contains(keyCode)) { return(true); } else { return(false); } } #endif return(UnityInput.GetKeyDown(keyCode)); }
private void HandleOpenMenu() { if (Input.GetKeyUp(KeyCode.Mouse1) || Input.GetKeyUp(KeyCode.Mouse0) || Input.GetKeyUp(KeyCode.Escape)) { if (currentMenu != null) { InvokeFunction(() => { currentMenu.Remove(); }); } } if (Input.GetKeyDown(KeyCode.Mouse1)) { handleOpenMenuClickPosStart = Input.mousePosition; } if (Input.GetKeyUp(KeyCode.Mouse1)) { if (handleOpenMenuClickPosStart == Input.mousePosition) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { var menu = hit.transform.GetComponent <IMenuOpenable>()?.Menu; if (menu != null) { currentMenu = new OptionsMenu(menu, GameObject.Find("Canvas")); } } } } }
protected override void Update() { base.Update(); // Escape handling if (UnityInput.GetKeyDown(KeyCode.Escape)) { switch (gameUIManager.state) { case State.Normal: if (gameUIManager.isTargetSelected) { gameUIManager.DeselectTarget(); } else { gameUIManager.Pause(); } break; case State.Building: gameUIManager.DeselectTarget(); break; } } }
public void OnUpdate() { AvatarManager avatarManager = AvatarManager.instance; if (Input.GetKeyDown(KeyCode.PageDown)) { avatarManager.SwitchToNextAvatar(); } else if (Input.GetKeyDown(KeyCode.PageUp)) { avatarManager.SwitchToPreviousAvatar(); } else if (Input.GetKeyDown(KeyCode.Home)) { SettingsManager.settings.isAvatarVisibleInFirstPerson = !SettingsManager.settings.isAvatarVisibleInFirstPerson; logger.Info($"{(SettingsManager.settings.isAvatarVisibleInFirstPerson ? "Enabled" : "Disabled")} first person visibility"); avatarManager.currentlySpawnedAvatar?.OnFirstPersonEnabledChanged(); } else if (Input.GetKeyDown(KeyCode.End)) { SettingsManager.settings.resizeMode = (AvatarResizeMode)(((int)SettingsManager.settings.resizeMode + 1) % 3); logger.Info($"Set resize mode to {SettingsManager.settings.resizeMode}"); avatarManager.ResizeCurrentAvatar(); } else if (Input.GetKeyDown(KeyCode.Insert)) { SettingsManager.settings.enableFloorAdjust = !SettingsManager.settings.enableFloorAdjust; logger.Info($"{(SettingsManager.settings.enableFloorAdjust ? "Enabled" : "Disabled")} floor adjust"); avatarManager.ResizeCurrentAvatar(); } }
private void CheckMouseLock() { if (ControlMode == Mode.MouseLocked || ControlMode == Mode.MouseScreenEdge) { if (UnityInput.mousePresent && (firstTime || UnityInput.GetMouseButtonDown(0))) { firstTime = false; if (ControlMode == Mode.MouseLocked) { Cursor.lockState = CursorLockMode.Locked; } else { Cursor.lockState = CursorLockMode.Confined; } } else if (UnityInput.GetKeyDown(KeyCode.F1)) { Cursor.lockState = CursorLockMode.None; } } else if (Cursor.lockState != CursorLockMode.None) { Cursor.lockState = CursorLockMode.None; } Cursor.visible = Cursor.lockState != CursorLockMode.Locked && !showCustomCursor; }
public static bool GetInputDown(IList <KeyCode> list) { return(ForAny(list, delegate(KeyCode keyCode) { return UInput.GetKeyDown(keyCode); })); }
private void Update() { if (Input.GetKeyDown(KeyCode.Escape) && UGL.sceneManager.currentScene.sceneName != "Title") { UGL.sceneManager.ChangeScene("Title"); } }
/// <summary> /// Decay flick /// </summary> protected override void Update() { base.Update(); // Edge pan if (m_DragPointer != null) { EdgePan(); } if (UnityInput.GetKeyDown(KeyCode.Escape)) { switch (m_GameUI.state) { case State.Normal: if (m_GameUI.isTowerSelected) { m_GameUI.DeselectTower(); } else { m_GameUI.Pause(); } break; case State.Building: m_GameUI.CancelGhostPlacement(); break; } } }
public override bool GetButtonPressed(Keybind bind) { if (bind.HasBinding(InputType.KeyboardMouse)) { return(UInp.GetKeyDown(bind.GetBinding(InputType.KeyboardMouse).KeyCode)); } return(false); }
private void Update() { if (_isActive) { if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return)) { Console.Instance.HistoryManager.AddToHistory(_inputField.text); Console.Instance.Execute(_inputField.text); _inputField.text = ""; } if (Input.GetKeyDown(_historyNextKeyCode)) { _inputField.text = Console.Instance.HistoryManager.Up(); _inputField.MoveTextEnd(false); } if (Input.GetKeyDown(_historyPreviousKeyCode)) { _inputField.text = Console.Instance.HistoryManager.Down(); _inputField.MoveTextEnd(false); } if (Input.GetKeyDown(_openCloseConsoleKey)) { StartCoroutine(Deactivate()); } if (Input.GetKeyDown(_completeCommandKeyCode)) { var matchingCommands = Console.Instance.GetMatchingCommands(_inputField.text); if (matchingCommands.Count == 1) { _inputField.text = matchingCommands.First(); _inputField.MoveTextEnd(false); } else { foreach (var cmd in matchingCommands) { Log(cmd); } if (matchingCommands.Count != 0) { Log(" "); } } } } else { if (Input.GetKeyDown(_openCloseConsoleKey)) { StartCoroutine(Acitvate()); } } }
private void HandleLandscapingInput() { if (TerrainPaintingEnabled) { if (Input.GetKeyDown(KeyCode.Equals)) { CycleTerrainTypeIndex(); } else if (Input.GetKeyDown(KeyCode.Minus)) { CycleTerrainTypeIndex(false); } } if (_isDragSelecting) { return; } if (TerrainModificationEnabled || TerrainPaintingEnabled) { if (Input.GetMouseButtonUp(0)) { var actionParams = GetLandscapingActionParameters(); if (TerrainModificationEnabled) { new RaiseTerrain(actionParams).ExecuteAction(); } else if (TerrainPaintingEnabled) { new PaintTerrain(actionParams).ExecuteAction(); } } else if (Input.GetMouseButtonUp(1)) { var actionParams = GetLandscapingActionParameters(); if (TerrainModificationEnabled) { new LowerTerrain(actionParams).ExecuteAction(); } else if (TerrainPaintingEnabled) { new PaintTerrain(actionParams).ExecuteAction(); } } else if (TerrainPaintingEnabled && Input.GetMouseButtonDown(2)) { var actionParams = GetLandscapingActionParameters(); new PaintTerrain(actionParams).ExecuteAction(); } } }
public static bool getButtonDown(int playerIndex, int button) { if (button < 0 || button >= 2) { throw new Exception("getButtonDown: Button must be 0 or 1, you entered: " + button); } else { return(UnityInput.GetKeyDown(m_PlayerInputs[playerIndex].Buttons[button])); } }
public bool GetButtonJustPressed() { if (this.isKey) { return(DefInput.GetKeyDown(this.key)); } else { return(DefInput.GetButtonDown(this.input)); } }
protected void InitKeyDownStream() { KeyDownStream = Observable.EveryUpdate() .Where (_ => Input.anyKeyDown) .SelectMany (_ => listenKeyCodes) .Where (key => Input.GetKeyDown(key) || Input.GetKey(key)) .Do (_ => E.Input.IsAnyKeyHoldDown = true); }
private void HandleWeaponSelectionIfNeeded() { if (UnityInput.GetKeyDown(settings.inputSceme.swapWeaponsSetup.swapBack)) { InvokeSelectWeaponEvent(ESelectWeaponEvent.previous); return; } if (UnityInput.GetKeyDown(settings.inputSceme.swapWeaponsSetup.swapForward)) { InvokeSelectWeaponEvent(ESelectWeaponEvent.next); } }
/// <inheritdoc /> public override void Update() { if (keywordRecognizer != null && keywordRecognizer.IsRunning) { for (int i = 0; i < Commands.Length; i++) { if (UInput.GetKeyDown(Commands[i].KeyCode)) { OnPhraseRecognized((ConfidenceLevel)RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.UtcNow, Commands[i].LocalizedKeyword); } } } }
/// <inheritdoc /> public override void Update() { using (UpdatePerfMarker.Auto()) { if (keywordRecognizer != null && keywordRecognizer.IsRunning) { for (int i = 0; i < m_SpeechCommandsArray.Length; i++) { if (UInput.GetKeyDown(m_SpeechCommandsArray[i].KeyCode)) { OnPhraseRecognized((ConfidenceLevel)RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.UtcNow, m_SpeechCommandsArray[i].LocalizedKeyword); } } } } }
/// <inheritdoc /> public override void Update() { Profiler.BeginSample("[MRTK] WindowsSpeechInputProvider.Update"); if (keywordRecognizer != null && keywordRecognizer.IsRunning) { for (int i = 0; i < Commands.Length; i++) { if (UInput.GetKeyDown(Commands[i].KeyCode)) { OnPhraseRecognized((ConfidenceLevel)RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.UtcNow, Commands[i].LocalizedKeyword); } } } Profiler.EndSample(); }
protected override bool PollPressed(KeyCode inputBind) { bool bRet = UInput.GetKeyDown(inputBind); if (bRet) { RetroEvents.Chapter("Input_" + BoundInputID.ToString()).Set(new KeyInputEvent(true, Time.deltaTime, IsJoystick, BoundInputID)); } return(bRet); }
public static IEnumerator WaitInput(GameObject button, string inputName, GameObject eventSystem, InputType inputTypeWanted) { yield return(new WaitUntil(() => UnityInput.anyKeyDown)); KeyCode pressed = default(KeyCode); try { pressed = (KeyCode)Enum.Parse(typeof(KeyCode), UnityInput.inputString, true); } catch (ArgumentException) { foreach (KeyCode keycode in Enum.GetValues(typeof(KeyCode))) { if (UnityInput.GetKeyDown(keycode)) { pressed = keycode; break; } } } var inputTypePressed = default(InputType); if (pressed >= KeyCode.JoystickButton0) { inputTypePressed = InputType.GAMEPAD; } else { inputTypePressed = InputType.KEYBOARD; } if (pressed != KeyCode.Escape && inputTypeWanted == inputTypePressed) { button.GetComponentInChildren <Text>().text = pressed.ToString(); var currentControl = Controls[inputName]; Controls[inputName] = new MultiControl { flags = currentControl.flags, button = currentControl.button, key = pressed }; } eventSystem.SetActive(true); Debug.Log("Button pressed " + pressed.ToString()); }
private void Update() { if (Input.GetKeyDown(KeyCode.F)) { _flashIsOn = !_flashIsOn; SelectFlashLight(_flashIsOn); } _zoom = Input.GetAxis("Mouse ScrollWheel"); if (_zoom > 0 || _zoom < 0) { SelectWeapon(); } if (Input.GetKeyDown(KeyCode.R)) { } }
// Update is called once per frame void Update() { if (LandscapingToolsEnabled) { HandleLandscapingInput(); } if (Input.GetKeyDown(KeyCode.P)) { ToggleTerrainPainting(); Debug.Log("What"); } if (Input.GetMouseButtonDown(2)) { Debug.Log($"Current tile terrain types: {MapInteractionManager.Instance.GetCurrentTile().GetVertexTerrainTypes()}"); } }
protected override void ManualUpdate() { base.ManualUpdate(); _timer.ManualUpdate(Time.deltaTime); if (Input.GetKeyDown(KeyCode.Alpha1)) { GameManager.Instance.autoPlay = true; _timer.Set(autoPlayDelay); message.GetComponent <TextMeshPro>().text = "Autoplay is activated!"; message.Show(2f); } if (Input.GetKeyDown(KeyCode.Alpha2)) { GameManager.Instance.autoPlay = false; message.GetComponent <TextMeshPro>().text = "Autoplay is dectivated!"; message.Show(2f); } if (Input.GetKeyDown(KeyCode.Alpha3)) { GameManager.Instance.InitHipPosition = hip.transform.position; message.GetComponent <TextMeshPro>().text = "Hip Position Update to " + GameManager.Instance.InitHipPosition; message.Show(2f); } if (Input.GetKeyDown(KeyCode.Space)) { StartCoroutine(FadeOutAndChangeScene("Main_Neuron", 2f)); } if (GameManager.Instance.autoPlay) { if (_timer.expired) { StartCoroutine(FadeOutAndChangeScene("Main", 2f)); _timer.Reset(); } } }
/// <summary> /// Detects which button is actively returning a value. /// </summary> /// <param name="required"></param> /// <param name="restrictions"></param> /// <returns></returns> public static string DetectButton(string[] required, params string[] restrictions) { int[] keyCodeValues = (int[])Enum.GetValues(typeof(KeyCode)); for (int i = 0; i < keyCodeValues.Length; i++) { if (UInput.GetKeyDown((KeyCode)keyCodeValues[i])) { string keyName = Enum.GetName(typeof(KeyCode), (KeyCode)keyCodeValues[i]); if (required.All(y => keyName.ToLower().Contains(y.ToLower())) && !restrictions.Any(x => keyName.ToLower().Contains(x.ToLower()))) { for (int ii = 0; ii < required.Length; ii++) { keyName = keyName.Replace(required[ii], ""); } return(keyName.ToLower()); } } } return(""); }
void Update() { //Open or close console if (UnityInput.GetKeyDown(_consoleToggleKey)) { ToggleVisibility(); } if (IsVisible) { //Command has been entered if (UnityInput.GetKeyDown(KeyCode.Return)) { _history.WriteToHistory(Input); RaiseInputReceived(); } HandleHistory(); } }
/// <inheritdoc /> public override void Update() { using (UpdatePerfMarker.Auto()) { base.Update(); if (keywordRecognizer != null && keywordRecognizer.IsRunning) { SpeechCommands[] commands = Commands; int commandsCount = commands?.Length ?? 0; for (int i = 0; i < commandsCount; i++) { SpeechCommands command = commands[i]; if (UInput.GetKeyDown(command.KeyCode)) { OnPhraseRecognized((ConfidenceLevel)RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.UtcNow, command.LocalizedKeyword); } } } } }
public EventModifiers GetRawEventModifiers() { EventModifiers eventModifiers = EventModifiers.None; if (UnityInput.GetKeyDown(KeyCode.LeftAlt) || UnityInput.GetKeyDown(KeyCode.RightAlt) || UnityInput.GetKey(KeyCode.LeftAlt) || UnityInput.GetKey(KeyCode.RightAlt)) { eventModifiers |= EventModifiers.Alt; } if (UnityInput.GetKeyDown(KeyCode.LeftControl) || UnityInput.GetKeyDown(KeyCode.RightControl) || UnityInput.GetKey(KeyCode.LeftControl) || UnityInput.GetKey(KeyCode.RightControl)) { eventModifiers |= EventModifiers.Control; } if (UnityInput.GetKeyDown(KeyCode.LeftShift) || UnityInput.GetKeyDown(KeyCode.RightShift) || UnityInput.GetKey(KeyCode.LeftShift) || UnityInput.GetKey(KeyCode.RightShift)) { eventModifiers |= EventModifiers.Shift; } return(eventModifiers); }
private void Update() { if (core.initialized) { core.Run(); #if UNITY_EDITOR for (int i = 0; i < keys.Length; i++) { if (UnityInput.GetKeyDown(keys[i])) { core.keyboard.JoyPadEvent(keys[i], true); } if (UnityInput.GetKeyUp(keys[i])) { core.keyboard.JoyPadEvent(keys[i], false); } } #endif } }
private void HandleHistory() { var historyRequested = false; var command = string.Empty; if (UnityInput.GetKeyDown(KeyCode.UpArrow)) { command = _history.ShiftBack(); historyRequested = true; } if (UnityInput.GetKeyDown(KeyCode.DownArrow)) { command = _history.ShiftForward(); historyRequested = true; } if (historyRequested && command != string.Empty) { Input = command; } }
void Update() { _nPrevTouchCount = _nCurTouchCount; _nCurTouchCount = UInput.touchCount; if ((_nPrevTouchCount != _nCurTouchCount && _nCurTouchCount == 4) || (UInput.GetKeyDown(KeyCode.BackQuote))) { if (IsOpen) { CloseConsole(); } else { OpenConsole(); } } if (UInput.GetKeyDown(KeyCode.Return) || UInput.GetKeyDown(KeyCode.KeypadEnter)) { SubmitCommand(); } }