Debugging
When something isn't working as expected, the best first stop is usually the "Input Debugger" in the Unity editor. This is a Unity editor window that is designed to provide access to the activity of the input system in both the editor and in connected players.
To open the input debugger, go to Window >> Analysis >> Input Debugger
in Unity's main menu in the editor.
Input Debugger
The debugger shows a tree breakdown of the state of the input system.
Item | Description |
---|---|
Devices | Input devices that are currently added to the system as well as a list of unsupported/unrecognized devices. |
Layouts | A breakdown of all registered control and device layouts. This is essentially the database of supported hardware and the knowledge of how to represent a given piece of input hardware. |
Actions | Only visible in play mode and only if there are actions that are currently enabled. Shows the list of all currently enabled actions and the controls they are bound to. See Debugging Actions. |
Users | Only visible when there is one or more InputUser instances. See documentation.Lists all currently active uers along with their active control schemes and devices, all their associated actions as well as the controls they are bound to. Note that PlayerInput uses InputUser underneath. This means that when using PlayerInput components, each player will have an entry here.See Debugging Users/PlayerInput. |
Settings | Shows the currently active Input System settings. |
Metrics | Shows some statics about Input System resource usage. |
Debugging Devices
You can double-click on any input device in the Devices
list in the debugger window to open a window showing information about the device, including real-time state information for its controls.
The top of the device window shows some general information about the specific device (such as name, manufacturer, serial number, etc).
Below that, you you see a view listing the devices controls, and their state. This is very useful when debugging input issues, as it allows you to verify if the data the input system is receiving from the input device is what you'd expect it to be in the first place. At the top of this view you will see the following buttons:
State
: Show the current state of the device in a new window. This is identical to the information as shown in this view, but is not updated, so you can take a slice of input state data and take the time to inspect it as needed.HID Descriptor
: Only shown for devices connected using the HID protocol. This will open a window showing the detailed HID specifications for the device and each of it's logical controls.
Finally, in the bottom of the window, you can inspect the event stream coming from the device. Any Input Event generated by the device will be shown here. You can double-click any event in the list to inspect the full device state at the time of the event. You can also select multiple events, and right click and choose "Compare" in the context menu to get a side-by-side difference between the state of the device at two different points in time.
Debugging Actions
Any enabled actions are listed in the Actions list in the debugger window (only shown if any actions are active and the editor is in play mode). If an action has actively bound controls, you can click the arrow next to the action to see them in the list. This is useful to debug whether your bindings correctly map to the controls you want them to bind to. See "Binding Resolution" for more info on how bindings are mapped to controls.
NOTE: Actions belonging to
InputUsers
will not be shown here, but will be shown in the Users list instead.
Debugging Users/PlayerInput
When there are multiple InputUser
instances – each PlayerInput
will implicitly create one –, the debugger will list each user along with its paired devices and active actions. The listed devices and actions work the same way as those shown in the devices and actions lists in the debugging window.
Debugging Layouts
The Layouts
list in the Debugger window shows a breakdown of all registered control and device layouts. This is essentially the database of supported hardware and the knowledge of how to represent a given piece of input hardware. This is mostly handy when you want to create a new device mapping, and want to see how it gets represented by the input system.
Debugging Remotely
You can connect input debugger to a player running on a device. This makes input activity from the player observable in the editor. The mechanism used by this is Unity's PlayerConnection
, i.e. the same mechanism by which the Unity profiler can be connected to a player.
NOTE: At the moment, debugging input in players is restricted to seeing devices and events from connected players. There is no support yet for seeing other input-related data such as actions and input users from players.
To see remote devices from built players, click the Remote Devices…
pop-up button in the Debugger window. You will see a list of remote player instance you can connect to (if there are any) - this is the same list as you will see in the Profiler and Console windows, and any connections are share between those windows. If any player(s) are connected, you can enable Show remote devices
in the same popup button. If players are connected, and Show remote devices
is enabled, the Devices
list in the debugger window will be split into a Local
section and a Remote
section. The Remote
section will show any input device from any connected player, and lets you inspect device state and events in real time, just as if it were a local device.
Input Visualizers
The Input System package comes with a "Visualizers" sample, which provides various components which let you monitor the state of various input system elements in real time using on-screen visualizers.
To install the sample, navigate to the Input System package in the package manager window (see "Installation"), and click "Import in project" next to the "Visualizers" sample.
The sampler provides two visualizer components:
InputControlVisualizer
Visualizes the current state of a single control in real-time. You can have multiple control visualizers to visualize the state of multiple controls. Check the GamepadVisualizer
, MouseVisualizer
or PenVisualizer
scenes in the sample for examples.
InputActionVisualizer
Visualizes the current state of a single action in real-time. You can have multiple action visualizers to visualize the state of multiple action. Can show the current value of the action, the control currently driving the action, as well as track the state of interactions over time. Check the SimpleControlsVisualizer
scene in the sample for examples.