Direct device workflow
Follow this workflow to read device controls directly in your scripts, for prototypes and single-platform projects.
The direct device workflow is the simplest input workflow, but the least flexible. It bypasses the Input Actions Editor, so you don't get the features that come with actions, such as bindings and rebinding. Use it for a quick implementation with one type of device. To support several types of input device or several platforms, use the Actions workflow instead. To compare the workflows, refer to Input System workflows comparison.
To read input directly from devices, complete the following task.
Read device controls in your scripts
To read device controls in a script:
- Get a reference to a device, such as the current gamepad with
Gamepad.current. For instructions, refer to Read devices directly. - Read the values of its controls in your
Updatemethod. For example, read the left stick withleftStick.ReadValue(), or check the right trigger withrightTrigger.wasPressedThisFrame. You can use the same approach for other device types, such as the keyboard or the mouse.
To open a sample scene that uses this workflow:
- In the Package Manager window, select the Input System package.
- Import the Simple Demo sample.
- Open the
SimpleDemo_UsingStatescene.
Note: This sample requires the Universal Render Pipeline (URP) package.