InputActionService

Holds the action maps in force and advances them once per frame from an IInputSource. Gameplay code reaches it through the static InputActions facade rather than resolving it.

Properties

Asset

(InputActionsAsset?) { get; set }: The asset currently driving the actions, or null before one is loaded.

Rebind

(InputRebind?) { get; set }: The rebinding currently listening for a control, or null when none is.

Public Methods

Load

public void Load(InputActionsAsset? asset)

Puts an asset's maps in force, replacing whatever was there.

Parameters:

  • asset (InputActionsAsset?): The maps to use, or null to unbind everything.

Find

public InputAction? Find(string path)

Finds an action by Map/Action or by a bare name.

Parameters:

  • path (string): The action to find.

Returns: InputAction?

  • The action, or null when nothing matches.

SetMapEnabled

public void SetMapEnabled(string name, bool enabled)

Enables or disables a map, so a menu can take input away from gameplay.

Parameters:

  • name (string): The map's name.
  • enabled (bool): Whether it should follow the devices.

Update

public void Update()

Recomputes every enabled map's actions. Called by SceneTicker before the update passes, so a component reading an action in OnUpdate sees this frame's value.

StartRebind

public InputRebind StartRebind(InputAction action, int bindingIndex = 0)

Starts listening for the next control the player presses and writes it into one of an action's bindings. The action itself keeps updating, so a game showing "press any key" should disable the map first.

Parameters:

  • action (InputAction): The action to rebind.
  • bindingIndex (int): Which of its bindings to rewrite. (Default: 0)

Returns: InputRebind

  • The operation, which reports when it has captured something.

CancelRebind

public void CancelRebind()

Abandons a rebinding in progress, leaving the binding as it was.

CaptureOverrides

public Dictionary<string, string> CaptureOverrides()

The player's own bindings, as paths keyed by Map/Action/index. What a settings screen writes to disk and restores on the next run.

Returns: Dictionary<string, string>

  • Only the bindings that differ from nothing; an empty map when no asset is loaded.

ApplyOverrides

public void ApplyOverrides(IReadOnlyDictionary<string, string>? overrides)

Copies stored bindings back onto the loaded asset. Entries naming nothing are ignored.

Parameters:

  • overrides (IReadOnlyDictionary<string, string>?): Paths keyed by Map/Action/index.