docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Create a device

    Once the system has chosen a layout for a device, it instantiates an InputDevice and populates it with InputControls as the layout dictates. This process is internal and happens automatically.

    Note

    You can't create valid InputDevices and InputControls by manually instantiating them with new. To guide the creation process, you must use layouts.

    After the Input System assembles the InputDevice, it calls FinishSetup on each control of the device and on the device itself. Use this to finalize the setup of the Controls.

    After an InputDevice is fully assembled, the Input System adds it to the system. As part of this process, the Input System calls MakeCurrent on the Device, and signals InputDeviceChange.Added on InputSystem.onDeviceChange. The Input System also calls InputDevice.OnAdded.

    Once added, the InputDevice.added flag is set to true.

    Add devices manually

    To add devices manually, you can call one of the InputSystem.AddDevice methods such as InputSystem.AddDevice(layout).

    // Add a gamepad. This bypasses the matching process and creates
    // a device directly
    // with the Gamepad layout.
    InputSystem.AddDevice<Gamepad>();
    
    // Add a device such that the matching process is employed:
    InputSystem.AddDevice(new InputDeviceDescription
    {
        interfaceName = "XInput",
        product = "Xbox Controller",
    });
    

    When a device is added, the Input System automatically issues a sync request on the device. This instructs the device to send an event representing its current state. Whether this request succeeds depends on the whether the given device supports the sync command.

    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)