示例#1
0
        private void OnKeyboardActed(object sender, KeyboardActEventArgs e)
        {
            string    key       = e.Key;
            KeyAction keyAction = e.KeyAction;

            if (key == Key.LeftShift.ToString() || key == Key.RightShift.ToString())
            {
                IsShiftPressed = (keyAction == KeyAction.Down || keyAction == KeyAction.Pressed);
            }
            else if (key == Key.LeftCtrl.ToString() || key == Key.RightCtrl.ToString())
            {
                IsCtrlPressed = (keyAction == KeyAction.Down || keyAction == KeyAction.Pressed);
            }
            else if (key == Key.LeftAlt.ToString() || key == Key.RightAlt.ToString())
            {
                IsAltPressed = (keyAction == KeyAction.Down || keyAction == KeyAction.Pressed);
            }
            else if (key == Key.Tab.ToString())
            {
                IsTablePressed = (keyAction == KeyAction.Down || keyAction == KeyAction.Pressed);
            }
            else
            {
                LastKeyClick = key.ToString().ToUpper();
            }
            Logger.Debug($"{key} {keyAction.ToString()}");
        }
    //Loads keycodes from player preferences
    void OnEnable()
    {
        //Comment out this line it you want to allow multiple simultaneous assignments
        KeyBinding.keyRemap += PreventDoubleAssign;

        KeyCode tempKey;

        tempKey = (KeyCode)PlayerPrefs.GetInt(keyAction.ToString());          //saved by the keyType, but returns int that corresponds to keyCode

        if (tempKey.ToString() == "None")
        {
            Debug.Log(keyCode.ToString());
            keyDisplay.text = keyCode.ToString();
            UpdateKeyCode();
            SaveKeyCode();
        }
        else
        {
            keyCode         = tempKey;
            keyDisplay.text = keyCode.ToString();
            UpdateKeyCode();
        }
    }
示例#3
0
文件: HotKey.cs 项目: Feddas/ggj2019
        void Update()
        {
            if (Input.GetKeyDown(key))
            {
                switch (action)
                {
                case KeyAction.Exit:
                    Exit();
                    break;

                case KeyAction.UnityEvent:
                    onKey.Invoke();
                    break;

                default:
                    throw new Exception("HotKey.cs does not support " + action.ToString());
                }
            }
        }
示例#4
0
	void animateDanceMove(KeyAction danceMove) {
		GetComponent<Animator> ().SetTrigger (danceMove.ToString ());
	}