I am having an issue with adding new bindings at runtime.
I have several existing actions in an action map and I need to allow the user to both rebind them and add completely new bindings.
I am using code similar to this:
myAction.AddBinding(newBindingPath);
After running this, I am able to see the new binding by accessing the bindings of the action:
myAction.bindings[0].effectivePath;
However, it does not trigger and it does not show up in the Input Debugger window (under actions).
I can add multiple new bindings like this and they all react the same.
If I then remap a binding (it can be a previously existing one or one of the new ones):
myAction.ApplyBindingOverride(bindingOverride);
I get an error in the console:
Binding count in old and new state must be the same
UnityEngine.InputSystem.InputActionMap:Enable()
Then all the new bindings show up in the debugger and they start working.
I have tried disabling the action map before adding the new bindings, but it doesn’t help.
Is there some method call that I need to make after adding a new binding in order to get it to refresh itself?