Class InputContextDefinition
A serializable data object that describes the settings for an InputContext, authored in the Unity Inspector via ScyllaInputContextConfiguration. At runtime, call CreateContext() to convert this definition into a live InputContext that can be registered and pushed onto the context stack.
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
[Serializable]
public class InputContextDefinition
Remarks
This class intentionally mirrors every settable property of InputContext so that all context configuration can be done in the Inspector without writing code. It also supports being created programmatically and passed directly to RegisterContext(InputContext) after calling CreateContext().
Call Validate(int) before registration during authoring to detect empty IDs, duplicate action map names, and conflicting flag combinations.
Action map names are compared case-insensitively during duplicate detection (in
Validate(int)) but are stored and passed to InputContext as-is.
Make sure the names match the exact casing used in the InputActionAsset.
Fields
BlocksLowerPriority
When true, this context prevents all contexts with a strictly lower
Priority from receiving input while this context is above them on the
stack. Corresponds to BlocksLowerPriority.
Declaration
[Tooltip("When enabled, all input contexts with a lower priority value than this one are prevented from receiving input while this context is active.")]
public bool BlocksLowerPriority
Field Value
| Type | Description |
|---|---|
| bool |
ConsumesAllInput
When true, this context prevents every context below it on the stack from
receiving input regardless of their priority values. This is a stronger mode than
BlocksLowerPriority and makes that flag redundant.
Corresponds to ConsumesAllInput.
Declaration
[Tooltip("When enabled, this context consumes all input and blocks every context below it regardless of individual blocking settings. Makes Blocks Lower Priority redundant.")]
public bool ConsumesAllInput
Field Value
| Type | Description |
|---|---|
| bool |
ContextID
Unique string identifier for the context produced by CreateContext(). This value is passed as ContextID and used in all push/pop/query operations. Must be unique across all registered contexts. Empty string will fail Validate(int) and will be skipped during Apply().
Declaration
[Tooltip("Unique string identifier for this input context. Referenced in PushContext and PopContext calls to activate or deactivate the context at runtime.")]
public string ContextID
Field Value
| Type | Description |
|---|---|
| string |
Description
Optional free-text description explaining when this context should be active and what gameplay state it represents. Not used at runtime; intended for authoring clarity.
Declaration
[Tooltip("Optional description explaining the purpose of this context and the gameplay situations in which it should be active.")]
public string Description
Field Value
| Type | Description |
|---|---|
| string |
DisabledActionMaps
Names of the Unity Input System action maps to disable when this context becomes the
top context. Applied before EnabledActionMaps. Names must match those
in the project's InputActionAsset exactly. Null and empty entries are skipped
by CreateContext().
Declaration
[Tooltip("List of InputActionAsset action map names that are automatically disabled when this context becomes active.")]
public List<string> DisabledActionMaps
Field Value
| Type | Description |
|---|---|
| List<string> |
DisplayName
Human-readable label for the context, shown in debug overlays and log messages. When empty, CreateContext() substitutes ContextID for the DisplayName so the label is never blank.
Declaration
[Tooltip("Human-readable name displayed in debug tools, logs, and the inspector for easier identification.")]
public string DisplayName
Field Value
| Type | Description |
|---|---|
| string |
EnabledActionMaps
Names of the Unity Input System action maps to enable when this context becomes the
top context. Names must match those in the project's InputActionAsset exactly.
Null and empty entries are skipped by CreateContext().
Duplicate entries and entries that also appear in DisabledActionMaps
will be reported as errors by Validate(int).
Declaration
[Tooltip("List of InputActionAsset action map names that are automatically enabled when this context becomes active.")]
public List<string> EnabledActionMaps
Field Value
| Type | Description |
|---|---|
| List<string> |
ExclusionGroup
Optional group identifier for mutual exclusivity. Contexts that share the same non-empty ExclusionGroup value are understood to never be active simultaneously (e.g., different movement modes like on-foot gameplay vs strategy camera). The conflict detection system in GetConflicts(string, string) uses this to skip false-positive binding conflicts between action maps that belong to mutually exclusive contexts.
Declaration
[Tooltip("Optional group identifier for mutual exclusivity. Contexts sharing the same non-empty value are never active simultaneously, so their bindings are not checked against each other for conflicts.")]
public string ExclusionGroup
Field Value
| Type | Description |
|---|---|
| string |
Remarks
An empty or null value means the context does not participate in any exclusion group, and its bindings are always checked for conflicts against all other contexts.
The group identifier is a plain string with no imposed naming convention.
Example values: "Movement", "CameraMode", "VehicleType".
Priority
Integer priority assigned to the Priority property.
Higher values indicate higher priority. When BlocksLowerPriority is
true, this context will block any context on the stack with a strictly lower
priority value. Valid range enforced in the Inspector: -100 to 100.
Declaration
[Tooltip("Numeric priority level that determines blocking order. Contexts with higher priority values can block input from reaching lower-priority contexts.")]
[Range(-100, 100)]
public int Priority
Field Value
| Type | Description |
|---|---|
| int |
Methods
CreateContext()
Constructs and returns a new InputContext populated with all settings from this definition. The returned context has not been registered with or pushed onto the IInputContextManager; pass it to RegisterContext(InputContext) or PushContext(InputContext) to activate it.
Declaration
public InputContext CreateContext()
Returns
| Type | Description |
|---|---|
| InputContext | A new InputContext whose properties mirror this definition's fields. When DisplayName is null or empty, ContextID is used as the display name. Null and empty entries in EnabledActionMaps and DisabledActionMaps are skipped. |
Validate(int)
Validates the fields of this definition and returns a list of diagnostic messages. Checks performed:
- Empty ContextID - Error.
- Both ConsumesAllInput and BlocksLowerPriority set - Warning (redundant flag).
- Empty or duplicate entries in EnabledActionMaps - Warning for empty, Error for duplicate.
- Empty or duplicate entries in DisabledActionMaps - Warning for empty, Error for duplicate.
- Action map names that appear in both EnabledActionMaps and DisabledActionMaps - Error.
Duplicate detection is case-insensitive. Does not modify any field values.
Declaration
public List<ContextValidationMessage> Validate(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of this definition in its containing list, used to construct human-readable error messages such as "Context at index 2 has empty Context ID." |
Returns
| Type | Description |
|---|---|
| List<ContextValidationMessage> | A list of ContextValidationMessage entries. An empty list means the definition passed all checks. |