Class InputRebindService
- Namespace
- Koala.Simulation.Input
- Assembly
- Koala.Simulation.dll
Provides utility methods for rebinding input actions at runtime.
Wraps Unity's InputAction.PerformInteractiveRebinding API
and integrates with InputSettingsService to automatically save
binding overrides into the simulation's save system.
Key features:
- Start an interactive rebind for any action and binding index
- Automatically saves and restores overrides
- Provides display strings for showing current bindings in UI
Commonly used from UI buttons or settings menus to allow players to customize their controls.
public static class InputRebindService
Examples
Example: Rebinding the "Jump" action
public void OnClick_RebindJump()
{
InputRebindService.StartRebind("Jump", 0,
onComplete: () =>
{
string display = InputRebindService.GetBindingDisplayName("Jump", 0);
Debug.Log($"Jump rebound → {display}");
});
}
Methods
| Name | Declaration | Description |
|---|---|---|
| GetBindingDisplayName(string, int) |
public static string GetBindingDisplayName(string actionName, int bindingIndex)
|
Gets the human-readable display name of a binding. Example: "Space", "Left Mouse Button", "Gamepad Button South". |
| StartRebind(string, int, Action, Action) |
public static void StartRebind(string actionName, int bindingIndex, Action onComplete = null, Action onCancel = null)
|
Starts an interactive rebind for the given action and binding index. Opens a "waiting for input" state. The next key/button pressed by the player will be assigned to the binding. Automatically saves overrides on completion. |