Ejemplo n.º 1
0
 private void Update()
 {
     if (this.selected)
     {
         InputKeyCode currentKeyPressed = InputManager.GetCurrentKeyPressed();
         if (currentKeyPressed != null)
         {
             KeyCode keyCode = currentKeyPressed.keyCode;
             if ((keyCode == KeyCode.Delete) || (keyCode == KeyCode.Backspace))
             {
                 this.DeleteKeyBinding();
                 this.SetText();
             }
             else if ((keyCode == KeyCode.Mouse0) || ((keyCode == KeyCode.Mouse1) || (keyCode == KeyCode.Escape)))
             {
                 this.OnDeselect();
             }
             else if (this.CurrentKeyAllow(keyCode))
             {
                 this.AssignKeyText(keyCode);
                 this.AssignNewKey(keyCode);
                 this.OnDeselect();
             }
             else if (keyCode != KeyCode.Mouse0)
             {
                 base.GetComponent <Animator>().SetTrigger("wrongKeyPressed");
                 this.SetText();
             }
         }
     }
 }
Ejemplo n.º 2
0
        public InputKeyCode GetCurrentKeyPressed()
        {
            InputKeyCode code2;
            IEnumerator  enumerator = Enum.GetValues(typeof(KeyCode)).GetEnumerator();

            try
            {
                while (true)
                {
                    if (enumerator.MoveNext())
                    {
                        object  current = enumerator.Current;
                        KeyCode key     = (KeyCode)current;
                        if (!Input.GetKey(key))
                        {
                            continue;
                        }
                        code2 = new InputKeyCode(key);
                    }
                    else
                    {
                        return(null);
                    }
                    break;
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(code2);
        }
Ejemplo n.º 3
0
 private void ChangeInputActionKey(InputActionId actionId, InputActionContextId contextId, int keyId, InputKeyCode newKeyCode)
 {
     foreach (InputAction action in this.nameToAction[actionId.actionName])
     {
         if (Equals(action.contextId, contextId))
         {
             KeyCode keyCode = (newKeyCode == null) ? KeyCode.None : newKeyCode.keyCode;
             this.RemoveKeysFromMap(action);
             this.SetActionKey(action, keyId, keyCode);
             this.AddKeysToMap(action);
             this.SaveKeys(action, keyId, keyCode);
         }
     }
 }