Hi there! I’m having trouble getting rebinding to work correctly and am hoping I’m making a mistake. I’m currently using V.1.2.0
-
I have some actions with some default bindings.
-
calling PerformInteractiveRebinding WILL create a new bind for an action.
-
it will not unbind the previous key. both keys will do the action.
-
if I save the binding overrides via SaveBindingOverridesAsJson, leave play mode, and then start the game again and apply them via LoadBindingOverridesFromJson, that will work - the old key is no longer functional.
Note that I even tried destroying the instance of my main Controls script (the object that inherits from IInputActionCollection2) and rebuilding it while in play mode, and that doesn’t fix the issue.
What am I missing?
PS: this is how I’m rebinding:
//"entry" is just a little gui button manager that has a reference to the InputAction.
entry.inputAction.Disable();
int keyboardIndex = entry.inputAction.GetBindingIndex(group: "Keyboard&Mouse");
rebindOperation = entry.inputAction.PerformInteractiveRebinding()
.OnComplete(operation => RebindComplete(entry, bindIndex))
.OnCancel(operating => RebindCanceled(entry, bindIndex))
.WithBindingGroup("Keyboard&Mouse")
.OnMatchWaitForAnother(0.1f)
.Start();
And RebindComplete looks like this:
void RebindComplete(UIRebindingEntry entry, int bindIndex)
{
rebindOperation.Dispose();
entry.inputAction.Enable();
rebindingFeedbackMenu.SetActive(false);
entry.UpdateOnRebindComplete(bindIndex);
PSInputs.OnBindingsUpdated();//saves the bindings to json.
InputBinding[] bindings = entry.inputAction.bindings.ToArray();
Debug.Log("finished rebinding this action: " + entry.inputAction.name);
for(int i =0; i < bindings.Length; i++)
{
Debug.Log(bindings[i].path);
}
}
Also note that the above Debug.Log only displays the binding I set, which implies to me that the old binding should not be active…