GetKeyDown() 공개 정적인 메소드

public static GetKeyDown ( KeyCode key ) : bool
key KeyCode
리턴 bool
예제 #1
0
파일: Input.cs 프로젝트: popcron/input
    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));
    }
예제 #2
0
 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;
            }
        }
    }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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;
        }
예제 #6
0
 public static bool GetInputDown(IList <KeyCode> list)
 {
     return(ForAny(list, delegate(KeyCode keyCode)
     {
         return UInput.GetKeyDown(keyCode);
     }));
 }
예제 #7
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape) && UGL.sceneManager.currentScene.sceneName != "Title")
     {
         UGL.sceneManager.ChangeScene("Title");
     }
 }
예제 #8
0
        /// <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;
                }
            }
        }
예제 #9
0
 public override bool GetButtonPressed(Keybind bind)
 {
     if (bind.HasBinding(InputType.KeyboardMouse))
     {
         return(UInp.GetKeyDown(bind.GetBinding(InputType.KeyboardMouse).KeyCode));
     }
     return(false);
 }
예제 #10
0
        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());
                }
            }
        }
예제 #11
0
        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();
                }
            }
        }
예제 #12
0
 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]));
     }
 }
예제 #13
0
 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);
            }
        }
예제 #16
0
 /// <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);
             }
         }
     }
 }
예제 #17
0
 /// <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);
                 }
             }
         }
     }
 }
예제 #18
0
        /// <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();
        }
예제 #19
0
        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);
        }
예제 #20
0
        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());
        }
예제 #21
0
        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))
            {
            }
        }
예제 #22
0
        // 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()}");
            }
        }
예제 #23
0
    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();
            }
        }
    }
예제 #24
0
 /// <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("");
 }
예제 #25
0
        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();
            }
        }
예제 #26
0
        /// <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);
                        }
                    }
                }
            }
        }
예제 #27
0
        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);
        }
예제 #28
0
파일: Loader.cs 프로젝트: play3577/em
        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
            }
        }
예제 #29
0
        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;
            }
        }
예제 #30
0
        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();
            }
        }