InputActionMapBinding

Abstract base class for declaring input action handlers using the [InputActionCallback] attribute. Subclass this to create a binding for one action map — mark methods with the attribute, and the system auto-discovers and wires them to Unity input actions via reflection.

Definition

Namespace: Paragon.Core.InputSystem Assembly: Paragon.dll

[Serializable]
public abstract class InputActionMapBinding

Remarks

InputActionMapBinding is the core class that makes the attribute-driven input system work. Each subclass represents the handler set for one InputActionMap. When Bind() is called:

  1. The target InputActionMap is resolved from the InputActionScheme

  2. Reflection scans the subclass for methods marked with [InputActionCallback]

  3. Each method is wrapped in an InputActionCallback (with automatic type conversion)

  4. Wrapped callbacks are subscribed to the appropriate InputAction phase event (started, performed, or canceled)

When Unbind() is called, all subscriptions are reversed and the callback dictionary is cleared.

Quick Lookup

Goal
How

Create a binding

Subclass InputActionMapBinding, add [InputActionCallback] methods

Bind callbacks

binding.Bind(autoEnable: true)

Unbind callbacks

binding.Unbind(autoDisable: true)

Enable the action map

binding.Enable()

Disable the action map

binding.Disable()

Check if enabled

binding.IsEnabled

Custom bind logic

Override OnBind()

Custom unbind logic

Override OnUnbind()

Properties

Name

The name of the action map this binding is associated with.

ActionMap

The resolved InputActionMap instance. Only available after Bind() has been called.

IsEnabled

Whether the underlying action map is currently enabled.

Methods

Initialize

Configures the binding with its parent scheme and action map name. Called by the bindings container during setup.

Parameter
Type
Description

inputScheme

InputActionScheme

The parent scheme component

actionMapName

string

Name of the action map in the InputActionAsset

Bind

Resolves the action map, discovers callback methods, wraps them, and subscribes to input action events.

Parameter
Type
Description

autoEnable

bool

If true, calls Enable() on the action map after binding. Defaults to false.

Binding process:

  1. Resolves InputActionMap from inputScheme.GetActionMap(actionMapName)

  2. Optionally enables the action map

  3. Scans for [InputActionCallback] methods via reflection

  4. Wraps each method in an InputActionCallback with type conversion

  5. Subscribes each callback to the matching InputAction's phase event

  6. Calls OnBind() for custom post-bind logic

Unbind

Unsubscribes all callbacks and clears the binding dictionary.

Parameter
Type
Description

autoDisable

bool

If true, calls Disable() on the action map after unbinding. Defaults to true.

Unbinding process:

  1. Calls OnUnbind() for custom pre-unbind logic

  2. Unsubscribes all callbacks from their InputAction phase events

  3. Clears the callback dictionary

  4. Optionally disables the action map

  5. Sets actionMap to null

Enable

Enables the underlying action map.

Disable

Disables the underlying action map.

GetCallbackMethods (static)

Returns all methods on a given type that have the [InputActionCallback] attribute.

Parameter
Type
Description

bindingType

Type

The binding subclass type to scan

Searches public and non-public instance methods.

Extension Points

Optional Overrides

Method
Purpose

OnBind()

Called after all callbacks are subscribed. Use for additional setup.

OnUnbind()

Called before callbacks are unsubscribed. Use for cleanup.

Implementation Requirements

When subclassing InputActionMapBinding, you MUST:

  1. Mark handler methods with [InputActionCallback("ActionName")]

  2. Ensure ActionName matches an action in the target InputActionMap

  3. Mark the class with [Serializable] for Inspector serialization

You SHOULD:

  • Use typed parameters (Vector2, float, etc.) for automatic value extraction

  • Specify InputActionPhase when you need non-default phases (default is PERFORMED)

  • Override OnBind() / OnUnbind() for custom setup and teardown

You SHOULD NOT:

  • Manually subscribe to InputAction events — the system handles this

  • Have two methods with the same (ActionName, Phase) pair — the dictionary key will conflict

  • Call Bind() without first calling Initialize() — the action map name will be null

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Basic movement binding

Binding with custom setup

See Also

Last updated