logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityInputRebindComponent

    No-code interactive rebinding for a single Input System binding: lets players reassign a control at runtime (the classic "press a key to rebind" settings row) without writing the rebinding boilerplate.
    Drive it from UI: wire a button to StartRebind() and a "reset" button to ResetBinding(); the current binding text is pushed through Serenity.InputGateway.Infrastructure.Components.UnityInputRebindComponent.onBindingDisplayChanged (wire it to a TMP/UI text's text setter), and Serenity.InputGateway.Infrastructure.Components.UnityInputRebindComponent.onRebindStarted / Serenity.InputGateway.Infrastructure.Components.UnityInputRebindComponent.onRebindStopped let you show a "Press any key…" prompt.

    Inheritance
    object
    UnityInputRebindComponent
    Namespace: Serenity.InputGateway.Infrastructure.Components
    Assembly: Serenity.UnityPlayerInput.Infrastructure.dll
    Syntax
    public class UnityInputRebindComponent : MonoBehaviour
    Remarks

    Wraps UnityEngine.InputSystem.InputActionRebindingExtensions.PerformInteractiveRebinding(UnityEngine.InputSystem.InputAction,System.Int32): the action is disabled during the rebind (required by the Input System) and re-enabled afterwards. When Serenity.InputGateway.Infrastructure.Components.UnityInputRebindComponent.persist is on, the asset's binding overrides are saved to UnityEngine.PlayerPrefs under Serenity.InputGateway.Infrastructure.Components.UnityInputRebindComponent.persistKey on every change and reloaded on enable, so rebinds survive restarts. This rebinds the referenced asset's binding, so it fits a shared-asset settings menu.

    Constructors

    UnityInputRebindComponent()

    Declaration
    public UnityInputRebindComponent()

    Methods

    ResetBinding()

    Clears any override on this binding, restoring its default, and persists the change.

    Declaration
    public void ResetBinding()

    StartRebind()

    Begins an interactive rebind: the next control the player actuates becomes the new binding.

    Declaration
    public void StartRebind()
    In this article
    © 2026 Serenity. All Rights Reserved