As title says, how do you save or load keybindings when a player changed them on runtime — for example, using PlayerPrefs or some ini file? So far, I haven’t found answer to this question in documentation or manuals.
P.S. I am speaking about new input system, of course.
// save overridePath from PerformInteractiveRebinding() OnComplete
private void completeControl(InputActionRebindingExtensions.RebindingOperation rO)
{
if(rO.selectedControl != null)
{
aIdWaitingToGetCompleted.action.ApplyBindingOverride(rO.selectedControl.path);
PlayerPrefs.SetString(aIdWaitingToGetCompleted.action.name, aIdWaitingToGetCompleted.action.bindings[0].overridePath); // the overridePath
PlayerPrefs.Save();
}
}
// apply override, use existing path if no override found
iA_rotate.ApplyBindingOverride(PlayerPrefs.GetString(iA_rotate.name, iA_rotate.bindings[0].path));
aIdWaitingToGetCompleted is a custom struct I use between input detection start and OnComplete handler. To get the action only, you can do so from rO too.
Also you might want to handle OnCancel.
The key for SetString is up to you of course, I use the name of the InputAction.