Rebinding UI. Works with TMPro, overlay, has same custom inspector as Rebinding UI sample (except of events section).
- Paste
InputManager.cs,RebindActionUI.cs,RebindActionUIEditor.csto project - In
InputManager.cs, replacePlayerInputActionsto your generated class - Add
RebindActionUIto object in scene, dragInputActionReferencethat you want to rebind, select binding - Add UnityEvent for button that will initiate the rebind, and select
StartInteractiveRebindmethod from object from previous step - To reset binding to default, create button and select
ResetToDefaultmethod call fromRebindActionUIcomponent - Access your input actions generated class instance through
InputManager:
private PlayerInputActions playerInputActions;
private void Awake(){
playerInputActions = InputManager.InputActions;
}- In order to subscribe to rebinding events:
private void OnEnable(){
InputManager.onRebindStarted += Started;
InputManager.onRebindCanceled += Canceled;
InputManager.onRebindComplete += Completed;
}
private void OnDisable(){
InputManager.onRebindStarted -= Started;
InputManager.onRebindCanceled -= Canceled;
InputManager.onRebindCompleted -= Completed;
}