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

    Interface IInputContextManager

    Defines the contract for a stack-based input context manager that controls which Unity Input System action maps are active at any given time and which contexts are permitted to process input based on a priority-and-blocking model.

    Namespace: Scylla.Input
    Assembly: ScyllaInput.dll
    Syntax
    public interface IInputContextManager
    Remarks

    An input context (represented by InputContext) describes a named mode of the game (e.g., Gameplay, Menu, Dialog) together with the set of action maps that should be enabled or disabled while that mode is active. Contexts are stacked in LIFO order; the context at the top of the stack is the active context.

    Blocking rules determine whether lower-level contexts on the stack still process input:

    • A context with BlocksLowerPriority set to true prevents all contexts with a lower Priority value from receiving input.
    • A context with ConsumesAllInput set to true prevents every context below it on the stack - regardless of priority - from receiving input. This is the strongest form of blocking.

    Before pushing or querying a context by ID, the context must be registered via RegisterContext(InputContext). Contexts can also be pushed directly (auto-registering if needed) using the PushContext(InputContext) overload.

    The concrete implementation is InputContextManager. Access it through ScyllaInput.Instance.ContextManager.

    Properties

    ActiveContext

    Gets the context currently at the top of the stack - the one whose action maps and blocking rules are applied most recently. Returns null when the stack is empty.

    Declaration
    InputContext ActiveContext { get; }
    Property Value
    Type Description
    InputContext

    ContextStack

    Gets a read-only snapshot of the current context stack ordered from top (index 0) to bottom (highest index). Contexts lower in the list may be blocked depending on the blocking flags of contexts above them.

    Declaration
    IReadOnlyList<InputContext> ContextStack { get; }
    Property Value
    Type Description
    IReadOnlyList<InputContext>

    IsInitialized

    Gets whether Initialize(IInputActionManager) has been called and completed successfully. Registration and stack operations are only valid while the manager is initialized. The value is reset to false by Shutdown().

    Declaration
    bool IsInitialized { get; }
    Property Value
    Type Description
    bool

    StackDepth

    Gets the number of contexts currently on the stack. A value of 0 means the stack is empty and ActiveContext is null.

    Declaration
    int StackDepth { get; }
    Property Value
    Type Description
    int

    Methods

    ClearContextStack()

    Removes all contexts from the stack by calling PopContext() repeatedly until the stack is empty. Each pop fires the standard events.

    Declaration
    void ClearContextStack()

    GetAllContexts()

    Returns a snapshot list containing all currently registered contexts in an unspecified order. The returned list is a new collection; modifications to it do not affect the manager's internal registry.

    Declaration
    IReadOnlyList<InputContext> GetAllContexts()
    Returns
    Type Description
    IReadOnlyList<InputContext>

    A new IReadOnlyList<T> of all registered InputContext instances. May be empty but never null.

    GetContext(string)

    Retrieves a registered context by its ID without affecting the stack.

    Declaration
    InputContext GetContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The ID of the context to retrieve. A null or empty string returns null.

    Returns
    Type Description
    InputContext

    The InputContext instance, or null if no context with that ID is registered.

    GetContextStackPosition(string)

    Returns the zero-based position of the context in the stack, where 0 is the top (most recently pushed) context.

    Declaration
    int GetContextStackPosition(string contextID)
    Parameters
    Type Name Description
    string contextID

    The context ID to locate. A null or empty string returns -1.

    Returns
    Type Description
    int

    The stack index of the context (0 = top), or -1 if the context is not on the stack.

    HasContext(string)

    Returns whether a context with the given ID is currently registered (not necessarily on the stack). Use IsContextActive(string) to check stack membership.

    Declaration
    bool HasContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The context ID to look up. A null or empty string returns false.

    Returns
    Type Description
    bool

    true if a context with that ID exists in the registry; false otherwise.

    Initialize(IInputActionManager)

    Initializes the context manager with a reference to the action manager used to apply action map enable/disable changes when contexts are pushed or popped. Must be called once before any stack operations. Calling a second time while already initialized logs a warning and has no effect.

    Declaration
    void Initialize(IInputActionManager actionManager)
    Parameters
    Type Name Description
    IInputActionManager actionManager

    The IInputActionManager used to enable and disable Unity Input System action maps. Must not be null.

    IsContextActive(string)

    Returns whether the context with the given ID is currently present anywhere on the context stack. Does not indicate whether the context is blocked; use ShouldProcessInput(string) for combined active+unblocked checking.

    Declaration
    bool IsContextActive(string contextID)
    Parameters
    Type Name Description
    string contextID

    The context ID to look for. A null or empty string returns false.

    Returns
    Type Description
    bool

    true if the context is on the stack at any position; false otherwise.

    IsContextBlocked(string)

    Returns whether the context with the given ID is prevented from receiving input by a higher-positioned context on the stack. A context that is not on the stack at all is also considered blocked (returns true).

    Declaration
    bool IsContextBlocked(string contextID)
    Parameters
    Type Name Description
    string contextID

    The context ID to evaluate. A null or empty string returns true (blocked).

    Returns
    Type Description
    bool

    true if the context is not on the stack, or if any context above it on the stack has ConsumesAllInput set to true, or has BlocksLowerPriority set to true with a higher Priority value. false if the context is on the stack and no blocking context is above it.

    PopContext()

    Removes the context currently at the top of the stack, applies the new top context's action maps, fires the OnContextPopped and OnContextChanged events, and publishes the corresponding Scylla events.

    Declaration
    InputContext PopContext()
    Returns
    Type Description
    InputContext

    The context that was removed, or null if the stack was empty. A warning is logged when attempting to pop an empty stack.

    PopToContext(string)

    Repeatedly calls PopContext() until the specified context is at the top of the stack. If the context is not on the stack at all, no contexts are popped and 0 is returned. Each pop fires the standard events.

    Declaration
    int PopToContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The ID of the target context that should become the new top after popping. A null or empty string returns 0 immediately.

    Returns
    Type Description
    int

    The number of contexts that were popped. Returns 0 if the target context is already at the top or is not on the stack.

    PushContext(InputContext)

    Pushes the given InputContext directly onto the top of the stack. If the context is not yet registered it is auto-registered before being pushed. Applies action maps and fires the same events as PushContext(string).

    Declaration
    bool PushContext(InputContext context)
    Parameters
    Type Name Description
    InputContext context

    The context to push. Must not be null. If the context is already on the stack the push is rejected and a warning is logged.

    Returns
    Type Description
    bool

    true if the context was pushed successfully; false if context is null or the context is already on the stack.

    PushContext(string)

    Pushes a registered context onto the top of the stack by its ID. Applies the context's action maps, updates IsActive and IsTopContext flags, fires the OnContextPushed and OnContextChanged events, and publishes the corresponding Scylla events.

    Declaration
    bool PushContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The ID of the context to push. The context must already be registered via RegisterContext(InputContext). A null or empty string returns false without logging.

    Returns
    Type Description
    bool

    true if the context was pushed successfully; false if the ID is null/empty, the context is not registered, or the context is already on the stack.

    RegisterContext(InputContext)

    Adds the given InputContext to the registry of known contexts so it can be pushed by ID later. Each context ID must be unique within the manager.

    Declaration
    bool RegisterContext(InputContext context)
    Parameters
    Type Name Description
    InputContext context

    The context to register. Must not be null and must have a non-null, non-empty ContextID.

    Returns
    Type Description
    bool

    true if the context was added successfully; false if context is null, has an empty ID, or a context with the same ID is already registered. A warning is logged in all failure cases.

    RemoveContext(string)

    Removes a context from any position in the stack, not just the top. If the removed context was the top context, the new top is activated and action maps are re-applied. Fires OnContextPopped and, if the top changed, OnContextChanged.

    Declaration
    bool RemoveContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The ID of the context to remove. A null or empty string returns false.

    Returns
    Type Description
    bool

    true if the context was found on the stack and removed; false if it was not on the stack.

    ShouldProcessInput(string)

    Returns whether a context is both on the stack and not blocked by any higher-priority context. Equivalent to IsContextActive(id) && !IsContextBlocked(id). Use this as the primary gate before polling input for a context-specific action.

    Declaration
    bool ShouldProcessInput(string contextID)
    Parameters
    Type Name Description
    string contextID

    The context ID to evaluate. A null or empty string returns false.

    Returns
    Type Description
    bool

    true if the context is active and not blocked; false if the context is absent from the stack or is blocked by a higher context.

    Shutdown()

    Shuts down the context manager: clears the context stack (firing all pop events), clears the registry, releases the action manager reference, sets IsInitialized to false, and nullifies all event delegates. Has no effect if the manager is not currently initialized.

    Declaration
    void Shutdown()

    UnregisterContext(string)

    Removes a context from the registry. If the context is currently on the stack it is also removed from the stack (equivalent to calling RemoveContext(string) first), triggering the appropriate events.

    Declaration
    bool UnregisterContext(string contextID)
    Parameters
    Type Name Description
    string contextID

    The ID of the context to unregister. A null or empty string causes the method to return false immediately without logging.

    Returns
    Type Description
    bool

    true if a context with the given ID was found and removed; false if no such context is registered.

    Update()

    Performs any per-frame maintenance required by the context manager. Called automatically by the Input module each frame. The current implementation is a no-op because context changes are entirely event-driven, but the method is reserved for future features such as time-based context expiry.

    Declaration
    void Update()

    Events

    OnContextChanged

    Raised whenever the active (top-of-stack) context changes, either because a new context was pushed or the top context was popped or removed. The first argument is the previous top context (may be null if the stack was empty), and the second argument is the new top context (may be null if the stack is now empty).

    Declaration
    event Action<InputContext, InputContext> OnContextChanged
    Event Type
    Type Description
    Action<InputContext, InputContext>

    OnContextPopped

    Raised after a context has been removed from the top of the stack (via PopContext()) or from an arbitrary position (via RemoveContext(string)) and its deactivation callback has been invoked. The argument is the removed context.

    Declaration
    event Action<InputContext> OnContextPopped
    Event Type
    Type Description
    Action<InputContext>

    OnContextPushed

    Raised after a context has been pushed onto the stack and its action maps have been applied. The argument is the newly pushed context.

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