docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Device assignments

    If the PlayerInput component has any Devices assigned, it matches these to the Control Schemes in the associated action asset, and only enables Control Schemes which match its Input Devices.

    Each PlayerInput can have one or more Devices assigned to it. By default, no two PlayerInput components are assigned the same Devices, but you can force this; to do so, manually assign Devices to a player when calling PlayerInput.Instantiate, or call InputUser.PerformPairingWithDevice on the InputUser of a PlayerInput.

    Control scheme auto-switching

    In single-player mode, if the actions asset defines Control Schemes, PlayerInput automatically switches to the Control Scheme that matches the Device the player is using. For example, if the player presses a button on a gamepad while the "Keyboard&Mouse" scheme is active, PlayerInput switches to the "Gamepad" scheme.

    To disable this behavior, do one of the following:

    • In the Inspector window, uncheck Auto-Switch.
    • In code, set PlayerInput.neverAutoSwitchControlSchemes to true.

    When a switch occurs, PlayerInput:

    1. Unpairs the player's current Devices.
    2. Pairs the Devices that match the new Control Scheme.
    3. Applies that scheme's binding mask.

    Any Device that isn't part of the new scheme remains unpaired.

    Note

    Unpairing a Device cancels any in-progress action driven by that Device and resets its interaction state. For example, if the player is holding a key when the switch occurs, releasing it afterward doesn't invoke the action's release or performed callbacks.

    Important

    Any actuation of an unpaired Device above a small threshold can trigger an auto-switch, so a switch can occur without a deliberate button press. Controls that the Device's layout marks as noisy or synthetic don't count. For example, the built-in TrackedDevice layout marks position and rotation as noisy, so tracking alone doesn't trigger a switch. Other controls on the same Device can still trigger one, such as an analog trigger or grip that drifts slightly from zero. Whether a given control counts depends on the Device's layout.

    If the player uses multiple Devices at the same time, for example, an XR controller and a keyboard, do one of the following:

    • Include all of those Devices and their bindings in the same Control Scheme.
    • Disable Auto-Switch.
    • Don't use Control Schemes.

    Otherwise, repeated auto-switching can unpair a Device that's still in use and cancel its in-progress actions.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)