-
Notifications
You must be signed in to change notification settings - Fork 331
Closed
Description
The function RequestNewBinding() in the following code is triggered by an Unity UI button to rebind my input action:
private void Awake() {
controls = new TestInputActions();
controls.TestMap.TestBinding.performed += NewactionOnPerformed;
}
private void OnDestroy() {
controls.TestMap.TestBinding.performed -= NewactionOnPerformed;
}
private void TestBindingOnPerformed(InputAction.CallbackContext callbackContext) {
Debug.Log("Action performed");
}
public void RequestNewBinding() {
InputAction actionToUse = inputActions.actionMaps[0].actions[0];
rebindOperation = actionToUse.PerformInteractiveRebinding().WithRebindAddingNewBinding().Start();
}Adding a rebind like this, will add the new binding to the InputActionsReference. However, it's only usable in play mode after forcing an update to the InputActionReference.
When I'm using the rebind without .WithRebindAddingNewBinding(). The rebind doesn't even seem to register at all.
Repro steps:
- Setup a simple InputAction with a button.
- Setup code similar to what I'm doing.
- Setup an Unity UI button which executes the code from step 2.
- Enter play mode and click the button.
- Press a new button for the binding to register.
- Exit play mode and re-open your
InputActionReferenceasset. - Notice a new binding has been added to your
InputActionReference. - Enter play mode and try executing
TestBindingOnPerformedusing your new button. - Notice that the function does not execute, however your old binding still works (as intended because we use
.WithRebindAddingNewBinding(). - Exit play mode and make a change to the
InputActionReferenceasset (without removing your newly added bindings). - Enter play mode and notice
TestBindingOnPerformednow executes whenever you press your newly added binding.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels