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.
An action is identified by the map that declares it and its name within that map,
and every lookup takes both. An action name is only unique inside its map, while a
map name is unique across everything registered, so the pair is the identity and a
name on its own is not one. Two maps each declaring a Look is ordinary and
fully supported: those are two actions, independently bound and independently
rebindable. Lookup is a single Dictionary hit on that pair.
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. Two maps declaring the same action name contribute two, because those are two actions. |
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 |
ActiveControlSchemeName
Gets the control scheme currently applied as a binding mask, or an empty string.
Declaration
public string ActiveControlSchemeName { get; }
Property Value
| Type | Description |
|---|---|
| string | The name last passed to SetActiveControlScheme(string), or an empty string when no scheme is applied and every binding is live. |
IsInitialized
Gets a value indicating whether the action manager has been initialized.
Declaration
public bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
RegisteredAssets
Gets every InputActionAsset currently registered, in registration order.
Declaration
public IReadOnlyList<InputActionAsset> RegisteredAssets { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<InputActionAsset> | The registered assets, in order. |
Remarks
Order is the order the assets were registered, which is also precedence: a map name two of them declare resolves to whichever registered last.
Methods
ClearActiveControlScheme()
Clears the control scheme mask, making every binding live again.
Declaration
public void ClearActiveControlScheme()
Remarks
Safe to call when no scheme was ever set.
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, string)
Returns the ScyllaInputAction registered under the given ID, or
null if no matching action exists.
Declaration
public ScyllaInputAction GetAction(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The action map declaring the action (e.g. |
| string | actionID | The action's name within that map (e.g. |
Returns
| Type | Description |
|---|---|
| ScyllaInputAction | The matching ScyllaInputAction, or |
Remarks
An action is identified by its map and its name together, and both are required.
An action name is only unique inside its map, while a map name is unique across
everything registered, so the pair is the identity and a name on its own is not
one. Two maps each declaring a Look is ordinary and fully supported: those
are two actions, and this returns whichever one the map names.
When action existence is uncertain, prefer TryGetAction(string, 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, string)
Returns the current float value of the action identified by
mapID and actionID.
Declaration
public float GetActionValue(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| 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, string)
Returns the current Vector2 value of the action identified by
mapID and actionID.
Declaration
public Vector2 GetActionVector2(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| 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, string)
Determines whether the action identified by mapID and actionID is
currently pressed or held down.
Declaration
public bool IsActionPressed(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| 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.
Prefer ScyllaInput.RegisterActionAsset unless there is a reason not to.
This method registers the maps and nothing else, while the module method also
rebuilds the rebindability provider so the new asset's sidecar is honoured, and
re-applies the active input context. Registration enables every map in the
asset, so without that second step a map the active context disables comes up
enabled and stays that way until something pushes a context again.
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.
SetActiveControlScheme(string)
Makes one control scheme the live one, disabling every binding outside it.
Declaration
public bool SetActiveControlScheme(string schemeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | schemeName | The control scheme's name as authored in the asset. Compared case-insensitively. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Applies the scheme as a binding mask (InputBinding.MaskByGroup) on every
registered asset that declares it. Until something does this, a control scheme is
authoring information and nothing more: enabling an action map enables all of its
bindings regardless of which scheme they name, so two actions bound to one control
under different schemes both fire.
A binding naming no scheme stays live under every mask, which is Unity's rule rather than a choice made here. Use it for bindings that belong to every layout.
An asset that declares no control scheme at all is left alone rather than masked, since masking it by a group it has never heard of would silently disable all of it. That is what lets a shared asset stay live under every scheme.
An asset that declares other schemes but not this one has its mask cleared instead, so it does not stay masked to whichever scheme was active before. The two cases look alike and behave differently: the first is opting out of scheme masking entirely, the second is simply not participating in this switch.
Not to be confused with IControlSchemeManager. That reports
which device class the player last used, for glyphs and prompts, and never changes
which bindings are live. This selects which bindings are live and says nothing
about devices.
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, string, out ScyllaInputAction)
Attempts to retrieve the ScyllaInputAction the given map declares under the given name.
Declaration
public bool TryGetAction(string mapID, string actionID, out ScyllaInputAction action)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The action map declaring the action. A |
| string | actionID | The action's name within that map. A |
| ScyllaInputAction | action | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Internally delegates to GetAction(string, string). Prefer this overload over GetAction(string, 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, string)
Determines whether the action identified by mapID and actionID was
canceled (button released) during the current frame.
Declaration
public bool WasActionCanceledThisFrame(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
WasActionPerformedThisFrame(string, string)
Determines whether the action identified by mapID and actionID was
in the Performed phase at any point during the current frame.
Declaration
public bool WasActionPerformedThisFrame(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| string | actionID | The ID of the action to query. A |
Returns
| Type | Description |
|---|---|
| bool |
|
WasActionStartedThisFrame(string, string)
Determines whether the action identified by mapID and actionID was
in the Started phase (button pressed down) during the current frame.
Declaration
public bool WasActionStartedThisFrame(string mapID, string actionID)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mapID | The map declaring the action. A |
| 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.