Files
Test/Library/PackageCache/com.unity.inputsystem@2436e68c60c4/Documentation~/monitor-devices.md
T
2026-11-01 23:39:55 +02:00

1.2 KiB

uid
uid
input-system-monitor-devices

Monitor devices

To be notified when new Devices are added or existing Devices are removed, use InputSystem.onDeviceChange.

InputSystem.onDeviceChange +=
    (device, change) =>
    {
        switch (change)
        {
            case InputDeviceChange.Added:
                // New Device.
                break;
            case InputDeviceChange.Disconnected:
                // Device got unplugged.
                break;
            case InputDeviceChange.Connected:
                // Plugged back in.
                break;
            case InputDeviceChange.Removed:
                // Remove from Input System entirely; by default, Devices stay in the system once discovered.
                break;
            default:
                // See InputDeviceChange reference for other event types.
                break;
        }
    }

InputSystem.onDeviceChange delivers notifications for other device-related changes as well. See the InputDeviceChange enum for more information.