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 InputActionMapBindingRemarks
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:
The target
InputActionMapis resolved from the InputActionSchemeReflection scans the subclass for methods marked with
[InputActionCallback]Each method is wrapped in an InputActionCallback (with automatic type conversion)
Wrapped callbacks are subscribed to the appropriate
InputActionphase event (started,performed, orcanceled)
When Unbind() is called, all subscriptions are reversed and the callback dictionary is cleared.
Quick Lookup
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.
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.
autoEnable
bool
If true, calls Enable() on the action map after binding. Defaults to false.
Binding process:
Resolves
InputActionMapfrominputScheme.GetActionMap(actionMapName)Optionally enables the action map
Scans for
[InputActionCallback]methods via reflectionWraps each method in an
InputActionCallbackwith type conversionSubscribes each callback to the matching
InputAction's phase eventCalls
OnBind()for custom post-bind logic
Unbind
Unsubscribes all callbacks and clears the binding dictionary.
autoDisable
bool
If true, calls Disable() on the action map after unbinding. Defaults to true.
Unbinding process:
Calls
OnUnbind()for custom pre-unbind logicUnsubscribes all callbacks from their
InputActionphase eventsClears the callback dictionary
Optionally disables the action map
Sets
actionMaptonull
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.
bindingType
Type
The binding subclass type to scan
Searches public and non-public instance methods.
Extension Points
Optional Overrides
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:
Mark handler methods with
[InputActionCallback("ActionName")]Ensure
ActionNamematches an action in the targetInputActionMapMark the class with
[Serializable]for Inspector serialization
You SHOULD:
Use typed parameters (
Vector2,float, etc.) for automatic value extractionSpecify
InputActionPhasewhen you need non-default phases (default isPERFORMED)Override
OnBind()/OnUnbind()for custom setup and teardown
You SHOULD NOT:
Manually subscribe to
InputActionevents — the system handles thisHave two methods with the same
(ActionName, Phase)pair — the dictionary key will conflictCall
Bind()without first callingInitialize()— the action map name will be null
Common Pitfalls
Action name must match exactly
The ActionName in [InputActionCallback("ActionName")] must match the name of an action in the bound InputActionMap. A mismatch will cause FindAction() to return null, resulting in a NullReferenceException.
Duplicate (ActionName, Phase) keys
Each (ActionName, InputActionPhase) pair must be unique within a binding class. Having two methods with the same action name and phase will throw a duplicate key exception during Bind().
Bind/Unbind symmetry
Always pair Bind() with Unbind(). Forgetting to unbind leaves dangling event subscriptions. The InputActionScheme.Disable() method handles this automatically.
Examples
Basic movement binding
Binding with custom setup
See Also
InputActionCallbackAttribute — attribute for declaring handlers
InputActionCallback — delegate wrapper with type conversion
InputActionPhase — phase enum
InputActionScheme — root component that manages bindings
Last updated