Class InputActionManager
Concrete implementation of IInputActionManager that manages the full lifecycle of Scylla input actions and action maps.
Implements
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public class InputActionManager : IInputActionManager
Remarks
InputActionManager combines three responsibilities:
-
Registration - accepts Unity
InputActionAssetobjects and hand-crafted ScyllaInputActionMap instances, wrapping them into Scylla types and indexing them for fast lookup. -
Modifier disambiguation - after every registration or removal,
recomputes which actions share a trigger key with a higher-modifier sibling
so that, for example,
Ctrl+Zdoes not also fire the bareZaction when the user holds Ctrl. - Event propagation - relays per-action callbacks to both the C# delegate events on this manager and to the Scylla Event eXchange (SEX) system via InputActionPerformedEvent, InputActionStartedEvent, and InputActionCanceledEvent.
Action lookup uses a two-step strategy: a direct Dictionary lookup on
the registered ID, followed by a linear per-map search when no slash is present
in the ID. When two actions from different maps share the same name, the second
one is stored under "MapID/ActionID" to avoid overwriting the first.
The result of GetAllActions() is cached and rebuilt lazily only when the action set changes, avoiding repeated allocations on stable configurations.
This class is not thread-safe. All methods must be called from the main thread.
Properties
ActionCount
Gets the total number of actions registered across all maps.
Declaration
public int ActionCount { get; }
Property Value
| Type | Description |
|---|---|
| int | A non-negative integer representing the sum of all actions in every registered
action map. When two actions from different maps share an |
ActionMapCount
Gets the total number of action maps currently registered with the manager.
Declaration
public int ActionMapCount { get; }
Property Value
| Type | Description |
|---|---|
| int | A non-negative integer. Returns |
IsInitialized
Gets a value indicating whether the action manager has been initialized.
Declaration
public bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
DisableActionMap(string)
Disables the action map with the given ID, preventing its actions from receiving input events.
Declaration
public void DisableActionMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The unique identifier of the action map to disable. An unrecognized ID is silently ignored. |
Remarks
Disabling a map that wraps a Unity InputActionMap calls
InputActionMap.Disable(). Disabling a manually-constructed map disables
each contained action individually. If the map is already disabled or the ID
is not found, the call is a no-op.
DisableAllActionMaps()
Disables every registered action map, preventing all actions from receiving input events.
Declaration
public void DisableAllActionMaps()
Remarks
Calls Disable() on each registered map in registration order. Maps that are already disabled are silently skipped. This is useful for global pause states or UI-modal scenarios where all gameplay input should be suppressed at once.
EnableActionMap(string)
Enables the action map with the given ID, allowing its actions to receive input events.
Declaration
public void EnableActionMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The unique identifier of the action map to enable. An unrecognized ID is silently ignored. |
Remarks
Enabling a map that wraps a Unity InputActionMap calls
InputActionMap.Enable(). Enabling a manually-constructed map enables
each contained action individually. If the map is already enabled or the ID
is not found, the call is a no-op.
EnableAllActionMaps()
Enables every registered action map, allowing all actions to receive input events.
Declaration
public void EnableAllActionMaps()
Remarks
Calls Enable() on each registered map in registration order. Maps that are already enabled are silently skipped.
GetAction(string)
Returns the ScyllaInputAction registered under the given ID, or
null if no matching action exists.
Declaration
public ScyllaInputAction GetAction(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The unique identifier of the action to retrieve. May be a plain action name
(e.g., |
Returns
| Type | Description |
|---|---|
| ScyllaInputAction | The matching ScyllaInputAction, or |
Remarks
The lookup first attempts an exact match against the internal dictionary. If the ID does not contain a slash and no exact match is found, the manager searches every registered map for an action with that name.
For unambiguous lookup of fully-qualified IDs, use the form
"MapID/ActionID". When action existence is uncertain, prefer
TryGetAction(string, out ScyllaInputAction) to avoid repeated null checks.
GetActionMap(string)
Returns the ScyllaInputActionMap registered under the given ID,
or null if not found.
Declaration
public ScyllaInputActionMap GetActionMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The unique identifier of the action map to retrieve. A |
Returns
| Type | Description |
|---|---|
| ScyllaInputActionMap | The matching ScyllaInputActionMap, or |
GetActionValue(string)
Returns the current float value of the action identified by
actionID.
Declaration
public float GetActionValue(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| float | The float value of the action, or |
Remarks
For actions with a Vector2 control type the returned value is the
magnitude of the 2D vector. For actions with a Vector3 control type
the returned value is the magnitude of the 3D vector. For all other control
types the raw float value is returned. See ReadFloat()
for the full type-dispatch logic.
GetActionVector2(string)
Returns the current Vector2 value of the action identified by
actionID.
Declaration
public Vector2 GetActionVector2(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| Vector2 | The |
Remarks
Only actions whose control type is "Vector2" (or an unspecified type
that can be cast to Vector2) will yield meaningful results. Actions
with float/button/axis control types return Vector2.zero.
See ReadVector2() for the full type-dispatch
logic.
GetActionsInMap(string)
Returns a read-only list of all actions belonging to the specified action map.
Declaration
public IReadOnlyList<ScyllaInputAction> GetActionsInMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The ID of the action map whose actions to retrieve. A |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<ScyllaInputAction> | A IReadOnlyList<T> of ScyllaInputAction objects belonging to the specified map, or Empty<T>() if the map was not found. |
GetAllActionMaps()
Returns a read-only list of all action maps currently registered with the manager.
Declaration
public IReadOnlyList<ScyllaInputActionMap> GetAllActionMaps()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<ScyllaInputActionMap> | A IReadOnlyList<T> of all registered ScyllaInputActionMap
instances. Never |
GetAllActions()
Returns a read-only snapshot of all actions currently registered across all action maps.
Declaration
public IReadOnlyList<ScyllaInputAction> GetAllActions()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<ScyllaInputAction> | A IReadOnlyList<T> of all registered ScyllaInputAction
instances. Never |
Remarks
The returned list is lazily rebuilt and cached. It is invalidated (and rebuilt on the next call) whenever an action is added or removed. Do not cache the returned reference across frames if actions may be added or removed dynamically.
HasActionMap(string)
Determines whether an action map with the given ID is currently registered.
Declaration
public bool HasActionMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The action map ID to check. Case-sensitive. A |
Returns
| Type | Description |
|---|---|
| bool |
|
Initialize()
Initializes the action manager, preparing it to accept registrations and process input events.
Declaration
public void Initialize()
Remarks
This method is called automatically by ScyllaInput during the module's
initialization phase. Calling it manually is not normally required. Subsequent
calls after the first successful initialization are no-ops.
IsActionMapEnabled(string)
Determines whether the action map with the given ID is currently enabled.
Declaration
public bool IsActionMapEnabled(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The unique identifier of the action map to query. An unrecognized ID returns
|
Returns
| Type | Description |
|---|---|
| bool |
|
IsActionPressed(string)
Determines whether the action identified by actionID is
currently pressed or held down.
Declaration
public bool IsActionPressed(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
RegisterActionAsset(InputActionAsset)
Registers all action maps and actions contained in a Unity
InputActionAsset, enabling them immediately.
Declaration
public void RegisterActionAsset(InputActionAsset asset)
Parameters
| Type | Name | Description |
|---|---|---|
| InputActionAsset | asset | The Unity |
Remarks
Calling this method calls InputActionAsset.Enable() on the asset
and wraps each InputActionMap found inside it into a
ScyllaInputActionMap. Each action within those maps is in
turn wrapped into a ScyllaInputAction and registered.
If the asset is null or has already been registered, a warning is
logged and the call is a no-op.
RegisterActionMap(ScyllaInputActionMap)
Registers a hand-crafted ScyllaInputActionMap and all of its contained actions with the manager.
Declaration
public void RegisterActionMap(ScyllaInputActionMap map)
Parameters
| Type | Name | Description |
|---|---|---|
| ScyllaInputActionMap | map | The ScyllaInputActionMap to register. Must not be |
Remarks
Use this overload when building action maps programmatically instead of from a
Unity InputActionAsset. After registration, modifier disambiguation
metadata is recomputed for all currently registered actions.
If map is null or a map with the same
MapID is already registered, a warning is logged and the call is a
no-op.
Shutdown()
Shuts down the action manager, unsubscribing all event listeners, disposing all registered maps and actions, and resetting internal state.
Declaration
public void Shutdown()
Remarks
After this method returns, IsInitialized is false and all
registered maps, actions, and cached data have been cleared. The manager must
be re-initialized via Initialize() before it can be used again.
This method is called automatically by ScyllaInput during module shutdown.
TryGetAction(string, out ScyllaInputAction)
Attempts to retrieve the ScyllaInputAction registered under the given ID.
Declaration
public bool TryGetAction(string actionID, out ScyllaInputAction action)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The unique identifier of the action to retrieve. A |
| ScyllaInputAction | action | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Internally delegates to GetAction(string). Prefer this overload over GetAction(string) when explicit existence checking is required, as it avoids separate null checks at the call site.
UnregisterActionAsset(InputActionAsset)
Removes all action maps and actions that were previously registered from the
given Unity InputActionAsset.
Declaration
public void UnregisterActionAsset(InputActionAsset asset)
Parameters
| Type | Name | Description |
|---|---|---|
| InputActionAsset | asset | The Unity |
Remarks
Each action map that originated from asset is unregistered
by name. If the asset is null or was never registered, the call is a
no-op. The asset itself is not disabled or destroyed; only the Scylla-side
registrations are removed.
UnregisterActionMap(string)
Unregisters an action map and all of its actions, and disposes the map.
Declaration
public void UnregisterActionMap(string mapID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The unique identifier of the action map to remove. Case-sensitive.
A |
Remarks
After removal, modifier disambiguation metadata is recomputed for all remaining
actions. If mapID is null, empty, or does not match
a registered map, the call is a no-op.
Update()
Advances the action manager state by one frame.
Declaration
public void Update()
Remarks
Called automatically each frame by ScyllaInput. In the current
implementation, action state is driven entirely by Unity's event callbacks
rather than polling, so this method is reserved for future per-frame tracking
needs and performs no work in the default implementation.
WasActionCanceledThisFrame(string)
Determines whether the action identified by actionID was
canceled (button released) during the current frame.
Declaration
public bool WasActionCanceledThisFrame(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
WasActionPerformedThisFrame(string)
Determines whether the action identified by actionID was
in the Performed phase at any point during the current frame.
Declaration
public bool WasActionPerformedThisFrame(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
WasActionStartedThisFrame(string)
Determines whether the action identified by actionID was
in the Started phase (button pressed down) during the current frame.
Declaration
public bool WasActionStartedThisFrame(string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
Events
OnActionCanceled
Raised when any registered action transitions to the Canceled phase
(button released).
Declaration
public event Action<ScyllaInputAction> OnActionCanceled
Event Type
| Type | Description |
|---|---|
| Action<ScyllaInputAction> |
Remarks
Cancellation is never suppressed by modifier disambiguation. Subscribers that track pressed/held state must always receive the cancel event to correctly reset their internal state even if the corresponding started/performed events were suppressed. A parallel InputActionCanceledEvent is also published through the SEX system.
OnActionMapDisabled
Raised when any registered action map is disabled via DisableActionMap(string) or DisableAllActionMaps().
Declaration
public event Action<ScyllaInputActionMap> OnActionMapDisabled
Event Type
| Type | Description |
|---|---|
| Action<ScyllaInputActionMap> |
OnActionMapEnabled
Raised when any registered action map is enabled via EnableActionMap(string) or EnableAllActionMaps().
Declaration
public event Action<ScyllaInputActionMap> OnActionMapEnabled
Event Type
| Type | Description |
|---|---|
| Action<ScyllaInputActionMap> |
OnActionPerformed
Raised when any registered action reaches the Performed phase.
Declaration
public event Action<ScyllaInputAction> OnActionPerformed
Event Type
| Type | Description |
|---|---|
| Action<ScyllaInputAction> |
Remarks
This event is subject to modifier disambiguation: it is not raised when the action is suppressed because a sibling action with a higher modifier depth shares the same trigger key and the required additional modifiers are held. A parallel InputActionPerformedEvent is also published through the SEX system for decoupled subscribers.
OnActionStarted
Raised when any registered action transitions to the Started phase
(button pressed down).
Declaration
public event Action<ScyllaInputAction> OnActionStarted
Event Type
| Type | Description |
|---|---|
| Action<ScyllaInputAction> |
Remarks
Subject to the same modifier disambiguation rules as OnActionPerformed. A parallel InputActionStartedEvent is also published through the SEX system.