I have this code here used to change key bindings on button press.
public void StartButtonRemapping(InputActionReference actionToRebind)
{
//Debug.Log("Successful Rebinding! "+ System.Environment.NewLine +"The reference before any changing: " + actionToRebind + " -- and it's action: " + actionToRebind.action);
if (actionToRebind == null)
return;
actionToRebind.action.Disable();
KeyBindButton.text = "...";
rebindOperation = actionToRebind.action.PerformInteractiveRebinding().OnMatchWaitForAnother(0.1f).WithControlsExcluding("Mouse").WithCancelingThrough("<Keyboard>/escape").
OnCancel(operation =>
{
KeyBindButton.text = "[" + actionToRebind.action.GetBindingDisplayString().ToUpper() + "]";
actionToRebind.action.Enable();
Debug.Log("The reference after a failed change: " + actionToRebind + " -- and it's action: " + actionToRebind.action);
rebindOperation.Dispose();
operation.Dispose();
}).
OnComplete(operation =>
{
KeyBindButton.text = "[" + actionToRebind.action.GetBindingDisplayString().ToUpper() + "]";
actionToRebind.action.Enable();
Debug.Log("The reference after a successful change: " + actionToRebind + " -- and it's action: " + actionToRebind.action);
rebindOperation.Dispose();
operation.Dispose();
}).
Start();
//Debug.Log("The reference after everything: " + actionToRebind + " -- and it's action: " + actionToRebind.action);
}
The part that I need help with is determining whether the input chosen to rebind to already exists for another key. If so, I would want to set the previously already bind to null so that the player can see that the key they changed the binding to already existed for another binding and would have to change it to a new key.