Add below setting for Unofficial Unity Package Manager Registry into scopedRegistries.
"scopedRegistries": [
{
"name": "Unofficial Unity Package Manager Registry",
"url": "https://upm-packages.dev",
"scopes": [
"com.unity.simpleanimation",
"com.stevevermeulen",
"jp.cysharp",
"dev.monry",
"dev.upm-packages"
]
}
]upm add package dev.upm-packages.keyeventhandlerYou can subscribe down, press and up key event.
usingUnityEngine;usingUniRx;usingKeyEventHandler;classSample:MonoBehaviour{privatevoidStart(){this.OnKeyDownAsObservable(KeyCode.Return).Subscribe(_ =>Debug.Log("On key down Return")).AddTo(this);this.OnKeyPressAsObservable(KeyCode.Space).Subscribe(_ =>Debug.Log("On key press Space")).AddTo(this);this.OnKeyUpAsObservable(KeyCode.Escape).Subscribe(_ =>Debug.Log("On key up Esc")).AddTo(this);}}These methods are implementing as extension method for Component or GameObject.
You need to set up a component called KeyEventLayer to accept key events. (If not set, it will be added automatically)
KeyEventLayer is a function to switch the validity of KeyEvents subscribed by the underlying GameObject in a batch.
KeyEventLayers can be nested, and KeyEvents will not be executed unless all KeyEventLayers in the parent-child relationship are valid.