UI Support
The Input System can be used to control any in-game UI created with the Unity UI package. The integration between the Input System and the UI system is handled by the InputSystemUIInputModule
component.
InputSystemUIInputModule
Component
The InputSystemUIInputModule
component acts as a drop-in replacement for the StandaloneInputModule
component provided by the Unity UI package. InputSystemUIInputModule
provides the same kind of functionality as StandaloneInputModule
, but it uses the Input System instead of the legacy Input Manager to drive UI input.
If you have a StandaloneInputModule
component on a game object, and the Input System is installed, Unity will show a button in the inspector offering to automatically replace it with a InputSystemUIInputModule
for you. The InputSystemUIInputModule
is preconfigured to use default input actions to drive the UI, but you can override that configuration to suit your needs.
You can use the following properties to configure InputSystemUIInputModule
:
Property | Description |
---|---|
Repeat Delay |
The Initial delay (in seconds) between an initial move action and a repeated move action. |
Repeat Rate |
The speed (in seconds) that the move action repeats itself once repeating. |
Actions Asset |
An `Input Action Asset`` containing all the actions to control the UI. You can chose which actions in the asset correspond to which UI inputs using the following properties. By default this is configured to reference the a built-in asset named "DefaultInputActions" which contains common default actions for driving UI. If you want to set up your own actions, create a custom input action asset and assign it here. When you assign a new asset reference to this field in the inspector, the editor will try a best guess approach to automatically map actions to UI inputs based on common naming conventions. |
The following properties let you map actions from the chosen Actions Asset
to UI input actions. In the inspector, these are shown as popup menus listing all the actions in the asset:
Property | Description |
---|---|
Point |
An action delivering a 2D screen position. Used as a cursor for pointing at UI elements to implement mouse-style UI interactions. |
Left Click |
An action mapping to the primary cursor button used to interact with UI. |
Middle Click |
An action mapping to the middle cursor button used to interact with UI. |
Right Click |
An action mapping to the secondary cursor button used to interact with UI. |
Scroll Wheel |
An action delivering gesture input to allow scrolling in the UI. |
Move |
An action delivering a 2D vector used to select currently active UI selectable. This allows a gamepad or arrow-key style control of the UI. |
Submit |
An action used to engage with or "click" the currently selected UI selectable. |
Cancel |
An action used to exit any interaction with the currently selected UI selectable. |
Tracked Device Position |
An action delivering a 3d position of one (or multiple) spatial tracking devices (such as an XR hand controller). In combination with Tracked Device Orientation , this allows XR-style UI interactions by pointing at UI selectables in space. |
Tracked Device Orientation |
An action delivering a quaternion representing the rotation of one (or multiple) spatial tracking devices (such as an XR hand controller). In combination with Tracked Device Position , this allows XR-style UI interactions by pointing at UI selectables in space. |
Tracked Device Select |
An action used to submit "clicks" on UI selectables coming from a spatial tracking device. This can for instance be mapped to the trigger button on an XR controller to allows XR-style UI interactions in combination with Tracked Device Position and Tracked Device Orientation . |
MultiplayerEventSystem
Component
The Input System can also handle multiple separate UI instances on the screen with separate controls. This is useful for having multiple local players sharing a single screen with different controllers, so that every player can control their own UI instance. To allow this, you need to replace the EventSystem
component from Unity with the Input System's MultiplayerEventSystem
component.
Unlike the EventSystem
component, it is allowed to have multiple MultiplayerEventSystems
active in the scene at the same time. That way, you can have multiple players, each with their own InputSystemUIInputModule
and MultiplayerEventSystem
components. That way each player can have their own set of actions driving their own UI instance. If you are using the PlayerInput
component, you can also set up PlayerInput
to automatically configure the player's InputSystemUIInputModule
to use the player's actions. See here to learn how.
The properties of the MultiplayerEventSystem
component are identical with those from the EventSystem
(as documented here). Additionally, the MultiplayerEventSystem
component adds a Player Root
property which you can set to a game object which contains all the UI selectables this event system should handle in it's hierarchy. Mouse input being processed by this event system will then ignore any UI selectables which are not on any game object in the hierarchy under Player Root
.