Advanced Input Action Maps and Runtime Rebinding
Creating accessibility-friendly games requires allowing players to rebind keyboard, mouse, and gamepad controls during live gameplay. Unity's modern Input System includes native asynchronous rebinding APIs that listen for player key presses and automatically update JSON configuration bindings.
using UnityEngine;
using UnityEngine.InputSystem;
public class RuntimeRebinder : MonoBehaviour
{
[SerializeField] private InputActionReference jumpAction;
public void StartInteractiveRebind()
{
jumpAction.action.Disable();
var rebindOp = jumpAction.action.PerformInteractiveRebinding()
.WithControlsExcluding("Mouse")
.OnComplete(operation =>
{
Debug.Log($"Rebound jump to: {jumpAction.action.bindings[0].effectivePath}");
operation.Dispose();
jumpAction.action.Enable();
})
.Start();
}
}