Scylla Framework
  • API Reference
Search Results for

    Show / Hide Table of Contents
    • Scylla.Input
      • AutoResolveChange
      • AutoResolveResult
      • BindingConflict
      • BindingStorageSettings
      • BindingStorageType
      • BridgeSettings
      • BufferedInput
      • ConfigActionEntry
      • ConfigBindingEntry
      • ConfigConflict
      • ConfigSchemeGroup
      • ContextValidationMessage
      • ContextValidationSeverity
      • ControlScheme
      • ControlSchemeChangedEvent
      • ControlSchemeManager
      • ControlSchemeType
      • GamepadButton
      • GamepadType
      • IBindingStorage
      • IControlSchemeManager
      • IInputActionManager
      • IInputBindingManager
      • IInputBridgeManager
      • IInputBufferManager
      • IInputContextManager
      • IInputHintsManager
      • IInputListener
      • IScyllaInputBridge
      • InputActionCanceledEvent
      • InputActionManager
      • InputActionPerformedEvent
      • InputActionStartedEvent
      • InputBindingManager
      • InputBindingsLoadedEvent
      • InputBindingsSavedEvent
      • InputBridgeManager
      • InputBridgeQueryMode
      • InputBufferConsumedEvent
      • InputBufferManager
      • InputBufferedEvent
      • InputConflictResolution
      • InputContext
      • InputContextChangedEvent
      • InputContextDefinition
      • InputContextManager
      • InputContextPoppedEvent
      • InputContextPushedEvent
      • InputDeviceChangedEvent
      • InputDeviceConnectedEvent
      • InputDeviceDisconnectedEvent
      • InputDeviceType
      • InputDeviceUtil
      • InputDisabledEvent
      • InputEnabledEvent
      • InputEventType
      • InputHint
      • InputHintChangedEvent
      • InputHintsManager
      • InputIconSet
      • InputIconSet.IconMapping
      • InputIconSetChangedEvent
      • InputLoggingSettings
      • InputRebindCancelledEvent
      • InputRebindCompletedEvent
      • InputRebindManager
      • InputRebindOperation
      • InputRebindStartedEvent
      • InputRebindUtils
      • JSONFileBindingStorage
      • ManagedRebindCancelledEvent
      • ManagedRebindCompletedEvent
      • ManagedRebindDataRefreshedEvent
      • ManagedRebindStartedEvent
      • PlayerPrefsBindingStorage
      • RebindMode
      • RebindSettings
      • ScyllaInput
      • ScyllaInput.Meta
      • ScyllaInputAction
      • ScyllaInputActionMap
      • ScyllaInputBinding
      • ScyllaInputConfiguration
      • ScyllaInputContextConfiguration
      • ScyllaKey
      • ScyllaKeyConverter
      • ScyllaModifier
      • UnityInputSystemBridge
    • Scylla.Input.Editor
      • ControlSchemeDrawer
      • DeviceStatusWidget
      • IconMappingDrawer
      • InputIconSetEditor
      • ScyllaInputConfigurationEditor
      • ScyllaInputContextConfigurationEditor
      • ScyllaInputDependencyProvider
      • ScyllaInputEditor
      • ScyllaInputMenuItems
      • ScyllaInputWizard

    Class InputContext

    Represents a named mode of the game (e.g., Gameplay, Menu, Dialog) that controls which Unity Input System action maps are active and whether this mode prevents lower-priority modes from receiving input.

    Inheritance
    object
    InputContext
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Scylla.Input
    Assembly: ScyllaInput.dll
    Syntax
    public class InputContext
    Remarks

    Contexts are managed by IInputContextManager in a LIFO stack. Push a context to activate it; pop it to return to the previous mode. Multiple contexts can coexist on the stack - the one at the top is the top context, but any context that is not blocked is still considered active and may process input.

    Use the fluent API to configure action maps and blocking behavior: new InputContext("Menu", priority: 80).SetBlocksLowerPriority(true).EnableActionMap("Menu")

    Action map semantics: when a context becomes the top context, its DisabledActionMaps are disabled first, then its EnabledActionMaps are enabled. Maps not listed in either collection are left in their current state.

    Blocking semantics: BlocksLowerPriority prevents contexts with a strictly lower Priority value from receiving input while this context is above them on the stack. ConsumesAllInput is a stronger variant that blocks every context below regardless of priority.

    Typically contexts are authored as InputContextDefinition data objects in the Inspector and converted to InputContext at runtime via CreateContext(). They can also be constructed directly in code.

    Constructors

    InputContext(string, string, int, string)

    Initializes a new InputContext with the specified ID and optional settings.

    Declaration
    public InputContext(string contextID, string displayName = null, int priority = 0, string description = null)
    Parameters
    Type Name Description
    string contextID

    Unique string identifier for this context, used in all push/pop/query operations. Must not be null or empty; an ArgumentException is thrown otherwise.

    string displayName

    Human-readable label shown in debug tools and logs. Defaults to the value of contextID when null or omitted.

    int priority

    Integer priority used by the blocking system. Higher values indicate higher priority. Contexts with a higher priority and BlocksLowerPriority set to true will prevent lower-priority contexts from receiving input. Defaults to 0.

    string description

    Optional free-text description of when and why this context is active. Defaults to Empty when null or omitted.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when contextID is null or empty.

    Properties

    BlocksLowerPriority

    Gets or sets whether this context blocks input for all contexts that have a strictly lower Priority and are positioned below this context on the stack. When true, those contexts return true from IsContextBlocked(string). When both this flag and ConsumesAllInput are true, this flag is redundant.

    Declaration
    public bool BlocksLowerPriority { get; set; }
    Property Value
    Type Description
    bool

    ConsumesAllInput

    Gets or sets whether this context prevents every context below it on the stack from receiving input, regardless of their Priority values. This is the strongest blocking mode and supersedes BlocksLowerPriority. Useful for modal dialogs or loading screens that must capture all input exclusively.

    Declaration
    public bool ConsumesAllInput { get; set; }
    Property Value
    Type Description
    bool

    ContextID

    Gets the unique string identifier for this context, set at construction time and immutable thereafter. Used in all push/pop/query operations by ID.

    Declaration
    public string ContextID { get; }
    Property Value
    Type Description
    string

    Description

    Gets the optional free-text description explaining when and why this context is active. Set at construction time. Returns Empty when not explicitly provided.

    Declaration
    public string Description { get; }
    Property Value
    Type Description
    string

    DisabledActionMaps

    Gets the read-only list of Unity Input System action map names that are disabled when this context becomes the top context. These are applied before EnabledActionMaps to ensure the intended set of active maps is correct.

    Declaration
    public IReadOnlyList<string> DisabledActionMaps { get; }
    Property Value
    Type Description
    IReadOnlyList<string>

    DisplayName

    Gets the human-readable display name for this context, used in debug overlays and log messages. Set at construction time; defaults to ContextID when not explicitly provided.

    Declaration
    public string DisplayName { get; }
    Property Value
    Type Description
    string

    EnabledActionMaps

    Gets the read-only list of Unity Input System action map names that are enabled when this context becomes the top context. Maps are enabled after the DisabledActionMaps have been disabled.

    Declaration
    public IReadOnlyList<string> EnabledActionMaps { get; }
    Property Value
    Type Description
    IReadOnlyList<string>

    ExclusionGroup

    Gets or sets the optional exclusion group identifier. Contexts that share the same non-empty ExclusionGroup are mutually exclusive: they are never active simultaneously. The conflict detection system uses this to skip false-positive binding conflicts between action maps belonging to contexts in the same group.

    Declaration
    public string ExclusionGroup { get; }
    Property Value
    Type Description
    string
    Remarks

    An empty or null value means the context does not participate in any exclusion group. Set from ExclusionGroup during CreateContext(), or assigned directly in code.

    IsActive

    Gets whether this context is currently on the context stack at any position. Set internally by the InputContextManager; do not set this directly. A context can be on the stack but not be the top context.

    Declaration
    public bool IsActive { get; }
    Property Value
    Type Description
    bool

    IsTopContext

    Gets whether this context is currently at the top of the context stack (i.e., it is the ActiveContext). Set internally by the InputContextManager; do not set this directly.

    Declaration
    public bool IsTopContext { get; }
    Property Value
    Type Description
    bool

    Priority

    Gets the integer priority of this context. Higher values represent higher priority. Used by the blocking system: when BlocksLowerPriority is true, this context will block any context with a strictly lower priority value that is below it on the stack. Set at construction time.

    Declaration
    public int Priority { get; }
    Property Value
    Type Description
    int

    Methods

    ClearActionMaps()

    Removes all entries from both the EnabledActionMaps and DisabledActionMaps lists. Useful when reconfiguring a context before it is next pushed onto the stack.

    Declaration
    public InputContext ClearActionMaps()
    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    DisableActionMap(string)

    Adds a Unity Input System action map name to the list of maps that will be disabled when this context becomes the top context. Disabled maps are applied before enabled maps. Duplicate entries are silently ignored.

    Declaration
    public InputContext DisableActionMap(string mapID)
    Parameters
    Type Name Description
    string mapID

    The name of the action map to disable. Null and empty values are ignored.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    DisableActionMaps(params string[])

    Adds multiple action map names to the list of maps that will be disabled when this context becomes the top context. Internally calls DisableActionMap(string) for each entry, so duplicates and empty strings are silently ignored.

    Declaration
    public InputContext DisableActionMaps(params string[] mapIDs)
    Parameters
    Type Name Description
    string[] mapIDs

    The names of the action maps to disable. Null elements and empty strings are skipped.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    EnableActionMap(string)

    Adds a Unity Input System action map name to the list of maps that will be enabled when this context becomes the top context. Duplicate entries are silently ignored. Null and empty strings are also ignored.

    Declaration
    public InputContext EnableActionMap(string mapID)
    Parameters
    Type Name Description
    string mapID

    The name of the action map to enable, as defined in the InputActionAsset. Null and empty values are ignored.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    EnableActionMaps(params string[])

    Adds multiple action map names to the list of maps that will be enabled when this context becomes the top context. Internally calls EnableActionMap(string) for each entry, so duplicates and empty strings are silently ignored.

    Declaration
    public InputContext EnableActionMaps(params string[] mapIDs)
    Parameters
    Type Name Description
    string[] mapIDs

    The names of the action maps to enable. Null elements and empty strings are skipped.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    SetBlocksLowerPriority(bool)

    Sets the BlocksLowerPriority flag and returns this context for fluent chained configuration.

    Declaration
    public InputContext SetBlocksLowerPriority(bool blocks)
    Parameters
    Type Name Description
    bool blocks

    true to prevent contexts with a strictly lower Priority from receiving input while this context is above them on the stack; false to allow lower-priority contexts to remain unblocked.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    SetConsumesAllInput(bool)

    Sets the ConsumesAllInput flag and returns this context for fluent chained configuration.

    Declaration
    public InputContext SetConsumesAllInput(bool consumes)
    Parameters
    Type Name Description
    bool consumes

    true to prevent every context below this one on the stack from receiving input, regardless of their Priority values; false to use the standard BlocksLowerPriority rule only.

    Returns
    Type Description
    InputContext

    This context instance, enabling fluent chained configuration calls.

    ToString()

    Returns a compact, human-readable summary of this context's current configuration, including its ID, priority, blocking flags, and the counts of its configured action maps. Format: [ContextID] Priority=N[, blocking][, consumes all] (X enabled, Y disabled)

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A diagnostic string describing this context's state.

    Overrides
    object.ToString()

    Events

    OnActivated

    Raised when this context becomes the top context on the stack, either because it was just pushed or because the context that was above it was popped or removed. The event argument is this context instance. Invoked by Scylla.Input.InputContext.InvokeActivated().

    Declaration
    public event Action<InputContext> OnActivated
    Event Type
    Type Description
    Action<InputContext>

    OnDeactivated

    Raised when this context is no longer the top context on the stack, either because another context was pushed on top of it, or because this context was popped or removed. The event argument is this context instance. Invoked by Scylla.Input.InputContext.InvokeDeactivated().

    Declaration
    public event Action<InputContext> OnDeactivated
    Event Type
    Type Description
    Action<InputContext>
    In this article
    Back to top Scylla Framework - Input Module API Documentation