Skip to content

Commit cc23cfe

Browse files
jechterRene Damm
authored andcommitted
NEW: Add docs for UI (#763).
1 parent c5545d4 commit cc23cfe

File tree

5 files changed

+507
-495
lines changed

5 files changed

+507
-495
lines changed

Packages/com.unity.inputsystem/Documentation~/Components.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ The devices assigned .
120120

121121
### UI Input
122122

123-
The [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component can work together with a [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) to drive the [UI system](UISupport.md).
123+
The [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component can work together with a [`InputSystemUIInputModule`](UISupport.md#inputsystemuiinputmodule-component) to drive the [UI system](UISupport.md).
124124

125-
To set this up, assign a reference to a [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) component in the [`UI Input Module`](../api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_uiInputModule) field of the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component. The [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) and [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) components should be configured to work with the same [`InputActionAsset`](Actions.md) for this to work.
125+
To set this up, assign a reference to a [`InputSystemUIInputModule`](UISupport.md#inputsystemuiinputmodule-component) component in the [`UI Input Module`](../api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_uiInputModule) field of the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component. The [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) and [`InputSystemUIInputModule`](UISupport.md#inputsystemuiinputmodule-component) components should be configured to work with the same [`InputActionAsset`](Actions.md) for this to work.
126126

127-
Now, when the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component configures the actions for a specific player, it will assign the same action configuration to the [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html). So the same device used to control the player will now be set up to control the UI.
127+
Now, when the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html) component configures the actions for a specific player, it will assign the same action configuration to the [`InputSystemUIInputModule`](UISupport.md#inputsystemuiinputmodule-component). So the same device used to control the player will now be set up to control the UI.
128128

129-
If you use [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) components to dispatch UI events, you can also use this setup to simultaneously have multiple UI instances on the screen, controlled by separate players.
129+
If you use [`MultiplayerEventSystem`](UISupport.md#multiplayereventsystem-component) components to dispatch UI events, you can also use this setup to simultaneously have multiple UI instances on the screen, controlled by separate players.
130130

131131
## `PlayerInputManager` Component
132132

@@ -166,7 +166,7 @@ If you enable the [`Split-Screen`](../api/UnityEngine.InputSystem.PlayerInputMan
166166
|[`Set Fixed Number`](../api/UnityEngine.InputSystem.PlayerInputManager.html#UnityEngine_InputSystem_PlayerInputManager_fixedNumberOfSplitScreens)|If this value is larger then zero, then the [`PlayerInputManager`](../api/UnityEngine.InputSystem.PlayerInputManager.html) will always split the screen into a fixed number of rectangles, regardless of the actual number of players.|
167167
|[`Screen Rectangle`](../api/UnityEngine.InputSystem.PlayerInputManager.html#UnityEngine_InputSystem_PlayerInputManager_splitScreenArea)|The normalized screen rectangle available for allocating player split-screens into.|
168168

169-
By default, any UI elements can be interacted with by any player in the game. However, in split-screen setups, it is possible to have screen-space UIs that are restricted to just one specific camera. See the (UI Input)[#ui-input] section above on how to set this up using the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html), [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) and [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) components.
169+
By default, any UI elements can be interacted with by any player in the game. However, in split-screen setups, it is possible to have screen-space UIs that are restricted to just one specific camera. See the (UI Input)[#ui-input] section above on how to set this up using the [`PlayerInput`](../api/UnityEngine.InputSystem.PlayerInput.html), [`InputSystemUIInputModule`](UISupport.md#inputsystemuiinputmodule-component) and [`MultiplayerEventSystem`](UISupport.md#multiplayereventsystem-component) components.
170170

171171
### `PlayerInputManager` Notifications
172172

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1-
////WIP: UI support is still being worked on
2-
31
# UI Support
2+
3+
The Input System can be used to control any in-game UI created with the [Unity UI package](https://docs.unity3d.com/Manual/UISystem.html). The integration between the Input System and the UI system is handled by the [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) component.
4+
5+
## `InputSystemUIInputModule` Component
6+
7+
The [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) component acts as a drop-in replacement for the [`StandaloneInputModule`](https://docs.unity3d.com/Manual/script-StandaloneInputModule.html) component provided by the Unity UI package. [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) provides the same kind of functionality as [`StandaloneInputModule`](https://docs.unity3d.com/Manual/script-StandaloneInputModule.html), but it uses the Input System instead of the legacy Input Manager to drive UI input.
8+
9+
If you have a [`StandaloneInputModule`](https://docs.unity3d.com/Manual/script-StandaloneInputModule.html) 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`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) for you. The [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) is preconfigured to use default input actions to drive the UI, but you can override that configuration to suit your needs.
10+
11+
[//]: # (TODO: add a screenshot)
12+
13+
You can use the following properties to configure [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html):
14+
15+
|Property|Description|
16+
|--------|-----------|
17+
|[`Repeat Delay`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_repeatDelay)|The Initial delay (in seconds) between an initial move action and a repeated move action.|
18+
|[`Repeat Rate`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_repeatDelay)|The speed (in seconds) that the move action repeats itself once repeating.|
19+
|[`Actions Asset`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_actionsAsset)|An [`Input Action Asset``](ActionAssets.md) 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 action asset](ActionAssets.md#creating-action-assets) 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.|
20+
21+
The following properties let you map actions from the chosen [`Actions Asset`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_actionsAsset) to UI input actions. In the inspector, these are shown as popup menus listing all the actions in the asset:
22+
23+
|Property|Description|
24+
|--------|-----------|
25+
|[`Point`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_point)|An action delivering a 2D screen position. Used as a cursor for pointing at UI elements to implement mouse-style UI interactions.|
26+
|[`Left Click`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_leftClick)|An action mapping to the primary cursor button used to interact with UI.|
27+
|[`Middle Click`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_middleClick)|An action mapping to the middle cursor button used to interact with UI.|
28+
|[`Right Click`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_rightClick)|An action mapping to the secondary cursor button used to interact with UI.|
29+
|[`Scroll Wheel`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_scrollWheel)|An action delivering gesture input to allow scrolling in the UI.|
30+
|[`Move`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_move)|An action delivering a 2D vector used to select currently active UI [selectable](https://docs.unity3d.com/Manual/script-Selectable.html). This allows a gamepad or arrow-key style control of the UI.|
31+
|[`Submit`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_submit)|An action used to engage with or "click" the currently selected UI [selectable](https://docs.unity3d.com/Manual/script-Selectable.html).|
32+
|[`Cancel`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_cancel)|An action used to exit any interaction with the currently selected UI [selectable](https://docs.unity3d.com/Manual/script-Selectable.html).|
33+
|[`Tracked Device Position`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDevicePosition)|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`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDeviceOrientation), this allows XR-style UI interactions by pointing at UI [selectables](https://docs.unity3d.com/Manual/script-Selectable.html) in space.|
34+
|[`Tracked Device Orientation`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDeviceOrientation)|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`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDevicePosition), this allows XR-style UI interactions by pointing at UI [selectables](https://docs.unity3d.com/Manual/script-Selectable.html) in space.|
35+
|[`Tracked Device Select`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDeviceSelect)|An action used to submit "clicks" on UI [selectables](https://docs.unity3d.com/Manual/script-Selectable.html) 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`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDevicePosition) and [`Tracked Device Orientation`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html#UnityEngine_InputSystem_UI_InputSystemUIInputModule_trackedDeviceOrientation).|
36+
37+
## `MultiplayerEventSystem` Component
38+
39+
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`](https://docs.unity3d.com/Manual/script-EventSystem.html) component from Unity with the Input System's [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) component.
40+
41+
[//]: # (TODO: add a screenshot)
42+
43+
Unlike the [`EventSystem`](https://docs.unity3d.com/Manual/script-EventSystem.html) component, it is allowed to have multiple [`MultiplayerEventSystems`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) active in the scene at the same time. That way, you can have multiple players, each with their own [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) and [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html)components. That way each player can have their own set of actions driving their own UI instance. If you are using the [`PlayerInput`](Components.md#playerinput-component) component, you can also set up [`PlayerInput`](Components.md#playerinput-component) to automatically configure the player's [`InputSystemUIInputModule`](../api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html) to use the player's actions. [See here to learn how.](Components.md#ui-input)
44+
45+
The properties of the [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) component are identical with those from the [`EventSystem`](https://docs.unity3d.com/Manual/script-EventSystem.html) (as documented [here](https://docs.unity3d.com/Manual/script-EventSystem.html)). Additionally, the [`MultiplayerEventSystem`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html) component adds a [`Player Root`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html#UnityEngine_InputSystem_UI_MultiplayerEventSystem_playerRoot) property which you can set to a game object which contains all the UI [selectables](https://docs.unity3d.com/Manual/script-Selectable.html) this event system should handle in it's hierarchy. Mouse input being processed by this event system will then ignore any UI [selectables](https://docs.unity3d.com/Manual/script-Selectable.html) which are not on any game object in the hierarchy under [`Player Root`](../api/UnityEngine.InputSystem.UI.MultiplayerEventSystem.html#UnityEngine_InputSystem_UI_MultiplayerEventSystem_playerRoot).

0 commit comments

Comments
 (0)