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 InputRebindOperation

    Represents a single interactive rebinding session for one binding slot on a Unity Input System action, providing a fluent configuration API, conflict notification, and automatic action re-enabling upon completion or cancellation.

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

    Instances are created by StartRebind(string, int) and must not be constructed directly. The internal constructor accepts only package-level callers via the internal access modifier.

    Lifecycle:

    1. StartRebind(string, int) creates the operation and calls Start() immediately. The action is disabled at this point to prevent it from responding to the input that will be used for rebinding.
    2. The player presses an input. Unity's Input System invokes the internal completion or cancellation callback, which sets IsActive to false, re-enables the action, performs conflict detection, and fires OnComplete (and OnCancelled when applicable).
    3. InputBindingManager receives the OnComplete callback, fires the manager-level events, disposes this operation, and clears its reference.

    Fluent configuration: the following methods may be called on the returned operation before it receives input (they have no effect once the underlying Unity operation has completed):

    • WithTimeout(float) - seconds to wait before auto-cancelling (default: 5 s).
    • WithCancelingThrough(string) - input path that aborts the rebind (default: <Keyboard>/escape).
    • WithControlFilter(string) - restrict accepted inputs to a specific device prefix.
    • WithExpectedControlType(string) - restrict accepted inputs to a control type (e.g., "Button").
    • WithExcludedPath(string) - exclude a specific input path from being selectable.

    Conflict detection: after a successful rebind, the manager queries all registered action maps for any binding whose effective path matches the newly bound path (excluding the action being rebound). If conflicts are found, OnConflictDetected is fired before OnComplete. It is the caller's responsibility to resolve conflicts (e.g., by clearing the competing binding via ClearBindingOverride(string, int)).

    Disposal: always disposed automatically by InputBindingManager after the operation completes. Manual disposal is safe but unnecessary in normal usage.

    Properties

    ActionID

    Gets the name of the Unity Input System action whose binding is being modified.

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

    The InputAction.name captured when the operation was created. Non-null.

    BindingIndex

    Gets the zero-based index of the binding within the action's bindings collection that this operation will replace.

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

    A non-negative integer in the range [0, action.bindings.Count).

    DeltaPollingEnabled

    Gets a value indicating whether mouse-delta polling is enabled for this operation (equivalent to Mode == RebindMode.DeltaPolling).

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

    DetectedModifiers

    Gets the modifier keys that were held when the input was captured during a modifier-aware rebind. Only valid after a successful completion with ModifierSupportEnabled set to true.

    Declaration
    public ScyllaModifier DetectedModifiers { get; }
    Property Value
    Type Description
    ScyllaModifier

    IsActive

    Gets a value indicating whether this rebind operation is currently listening for player input.

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

    true from the moment Start() is called until the underlying Unity operation fires its completion or cancel callback; false before Start() and after any terminal event.

    Mode

    Gets the rebind strategy this operation uses to capture input. See RebindMode for the available strategies.

    Declaration
    public RebindMode Mode { get; }
    Property Value
    Type Description
    RebindMode

    ModifierSupportEnabled

    Gets a value indicating whether modifier-aware keyboard polling is enabled for this operation (equivalent to Mode == RebindMode.ModifierPolling).

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

    NeedsPolling

    Gets a value indicating whether this operation requires per-frame Update() calls by its owner (any custom polling mode).

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

    NewPath

    Gets the Unity Input System control path that was assigned after a successful rebind.

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

    A non-null control path after a successful completion; null while the operation is active or after a cancellation. Reflects the binding's effectivePath immediately after the Unity rebind operation applies the override.

    OriginalPath

    Gets the Unity Input System control path that was effective on the target binding immediately before this operation started.

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

    A control path string (e.g., "<Keyboard>/space") representing the binding that will be restored if the operation is cancelled. May be null if the binding had no effective path at the time of creation.

    WasCancelled

    Gets a value indicating whether the operation was cancelled before the player pressed a valid input.

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

    true after the cancel input path is pressed, the timeout elapses, or Cancel() is called programmatically; false before the operation ends and after a successful completion.

    WasCleared

    Gets a value indicating whether the player pressed the clear binding key during the rebind, requesting that the binding be removed (set to empty path).

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

    true after the configured clear binding key is pressed; false otherwise. When true, WasSuccessful is also true and NewPath is empty string.

    WasSuccessful

    Gets a value indicating whether the operation completed with the player successfully pressing a new input.

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

    true only after OnComplete has fired with success = true. false before completion and after cancellation.

    Methods

    Cancel()

    Programmatically cancels the active rebind session, triggering the cancellation callbacks and restoring the original binding path.

    Declaration
    public void Cancel()
    Remarks

    Delegates to the underlying Unity rebinding operation's Cancel method, which asynchronously invokes the cancel callback registered in Start(). If the operation is not active (IsActive is false), a warning is logged and the call is ignored.

    Dispose()

    Releases all resources held by this rebind operation, including the underlying Unity rebinding operation object.

    Declaration
    public void Dispose()
    Remarks

    If the operation is still active when Dispose is called, Cancel() is invoked first. All event handlers (OnComplete, OnConflictDetected, OnCancelled) are cleared to prevent dangling references. Calling Dispose more than once is safe.

    Start()

    Begins the interactive rebinding session by disabling the target action and starting Unity's interactive rebinding operation with the configured parameters.

    Declaration
    public void Start()
    Remarks

    This method is called automatically by StartRebind(string, int); callers do not need to invoke it manually on the returned operation. Calling it a second time while IsActive is true logs a warning and returns immediately without effect.

    The target action is disabled for the duration of the session to prevent it from intercepting the input that should be bound. It is automatically re-enabled when the session ends, whether through success or cancellation.

    After this method returns, IsActive is true and the operation is waiting for input from the player.

    Update()

    Performs per-frame polling for any custom polling mode enabled on this operation (modifier-aware keyboard polling or mouse-delta polling). Must be called each frame while IsActive is true and NeedsPolling is true.

    Declaration
    public void Update()
    Remarks

    Modifier mode reads Keyboard.current and Mouse.current directly to detect key/mouse-button presses and modifier combinations. Three completion scenarios are supported:

    1. Non-modifier key or mouse button pressed (with or without modifiers held): completes with key/button + modifiers.
    2. Modifier held, then released without pressing another key: completes with modifier key alone.
    3. Escape pressed or timeout elapsed: cancels the operation.

    Delta mode reads Mouse.current.delta and completes with <Mouse>/delta when the frame's movement magnitude exceeds Scylla.Input.InputRebindOperation.DEFAULT_DELTA_POLLING_MAGNITUDE_THRESHOLD. Escape and clear-binding keys are honored.

    Has no effect when NeedsPolling is false or when IsActive is false.

    WithCancelingThrough(string)

    Sets the Unity Input System control path that will cancel the rebind operation when pressed by the player.

    Declaration
    public InputRebindOperation WithCancelingThrough(string path)
    Parameters
    Type Name Description
    string path

    A Unity Input System control path (e.g., "<Keyboard>/escape"). The default is "<Keyboard>/escape". Pass an empty string or null to disable the cancel path entirely (the player would then need to wait for the timeout or for a programmatic Cancel() call).

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    WithClearBinding(string)

    Sets the Unity Input System control path that clears (unbinds) the binding when pressed during an active rebind session.

    Declaration
    public InputRebindOperation WithClearBinding(string path)
    Parameters
    Type Name Description
    string path

    A Unity Input System control path (e.g., "<Keyboard>/delete"). When this input is detected, the rebind completes with WasCleared set to true and NewPath set to empty string. Pass null to disable the clear binding feature.

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    WithControlFilter(string)

    Restricts accepted inputs to controls on devices whose path starts with the given prefix, allowing rebinds to be scoped to a particular device class.

    Declaration
    public InputRebindOperation WithControlFilter(string devicePrefix)
    Parameters
    Type Name Description
    string devicePrefix

    A Unity Input System device path prefix (e.g., "<Keyboard>", "<Gamepad>"). Only controls whose full path begins with this prefix are eligible for selection. Pass null or empty string to clear the filter (all devices accepted).

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    WithDeltaMagnitudeThreshold(float)

    Sets the minimum per-frame mouse-delta magnitude (in pixels) required to complete a delta-polling rebind. Only meaningful when WithDeltaPolling(bool) has been enabled.

    Declaration
    public InputRebindOperation WithDeltaMagnitudeThreshold(float pixels)
    Parameters
    Type Name Description
    float pixels

    Positive threshold in pixels.

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    Remarks

    Lower values make the rebind more sensitive (completes on tiny cursor movements); higher values require more deliberate motion to avoid false positives from tremor or sensor noise. The default is 2.0 pixels. Values below 0 or above a sanity ceiling are clamped to the default.

    WithDeltaPolling(bool)

    Enables or disables mouse-delta polling for this rebind operation. When enabled, Start() skips Unity's interactive rebinding and instead uses per-frame mouse-delta polling via Update() to capture <Mouse>/delta when the player moves the mouse.

    Declaration
    public InputRebindOperation WithDeltaPolling(bool enabled)
    Parameters
    Type Name Description
    bool enabled

    true to enable delta polling; false for standard Unity rebind.

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    Remarks

    When delta polling is enabled, the caller (or the InputBindingManager) must call Update() each frame while IsActive is true.

    This mode exists because Unity's interactive rebinding does not reliably capture <Mouse>/delta - a noisy, continuous Vector2 control - even with WithoutIgnoringNoisyControls configured.

    WithExcludedPath(string)

    Adds a Unity Input System control path to the exclusion list, preventing the player from selecting it during this rebind session.

    Declaration
    public InputRebindOperation WithExcludedPath(string path)
    Parameters
    Type Name Description
    string path

    A Unity Input System control path to exclude (e.g., "<Mouse>/position"). Null and empty strings are silently ignored. This method may be called multiple times to accumulate additional exclusions.

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    WithExpectedControlType(string)

    Restricts accepted inputs to controls of the specified Unity Input System control type, ensuring the bound control produces a value compatible with the action's expected data.

    Declaration
    public InputRebindOperation WithExpectedControlType(string type)
    Parameters
    Type Name Description
    string type

    A Unity Input System control type name such as "Button", "Axis", or "Vector2". Pass null or empty string to remove the type constraint (any control type accepted).

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    WithModifierSupport(bool)

    Enables or disables modifier-aware keyboard polling for this rebind operation. When enabled, Start() skips Unity's interactive rebinding and instead uses per-frame keyboard polling via Update() to detect modifier+key combos (e.g., Shift+A, Ctrl+Shift+B).

    Declaration
    public InputRebindOperation WithModifierSupport(bool enabled)
    Parameters
    Type Name Description
    bool enabled

    true to enable modifier polling; false for standard Unity rebind.

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    Remarks

    When modifier support is enabled, the caller (or the InputBindingManager) must call Update() each frame while IsActive is true.

    After a successful rebind, DetectedModifiers contains the modifier flags that were held when the key was pressed.

    WithTimeout(float)

    Sets the maximum number of seconds the operation will wait for player input before automatically cancelling.

    Declaration
    public InputRebindOperation WithTimeout(float seconds)
    Parameters
    Type Name Description
    float seconds

    A positive value in seconds. The default is 5.0 seconds. Pass 0 or a negative value to disable the timeout entirely (Unity's Input System treats non-positive values as no timeout).

    Returns
    Type Description
    InputRebindOperation

    This operation instance, enabling method chaining.

    Events

    OnCancelled

    Raised when the operation is cancelled - either because the player pressed the configured cancel input path, the timeout elapsed, or Cancel() was called programmatically.

    Declaration
    public event Action OnCancelled
    Event Type
    Type Description
    Action
    Remarks

    This event is fired immediately before OnComplete (which will be called with success = false). The original binding path remains in place after cancellation.

    OnComplete

    Raised when the rebind operation terminates, regardless of whether the player successfully pressed an input or the operation was cancelled or timed out.

    Declaration
    public event Action<bool, string> OnComplete
    Event Type
    Type Description
    Action<bool, string>
    Remarks

    The two parameters are:

    1. bool successtrue if the player pressed a valid input and NewPath has been updated; false if the operation was cancelled (by the cancel input, timeout, or programmatically via Cancel()).
    2. string newPathThe Unity Input System control path that was bound on success (e.g., "<Keyboard>/space"), or null on failure.

    InputBindingManager subscribes to this event to perform cleanup and fire the manager-level events. After the manager's handler runs, the handler is unsubscribed and the operation is disposed.

    OnConflictDetected

    Raised after a successful rebind if one or more existing bindings share the newly assigned input path. Fired before OnComplete so that subscribers can resolve conflicts (e.g., clear competing bindings) before the binding manager propagates the completion.

    Declaration
    public event Action<IReadOnlyList<BindingConflict>> OnConflictDetected
    Event Type
    Type Description
    Action<IReadOnlyList<BindingConflict>>
    Remarks

    The argument is a non-null, read-only list of BindingConflict instances, one per colliding binding. The action being rebound is automatically excluded from the conflict scan.

    Implements

    IDisposable

    See Also

    StartRebind(string, int)
    CancelRebind()
    BindingConflict
    In this article
    Back to top Scylla Framework - Input Module API Documentation