XR Interaction Toolkit Sample
This sample demonstrates the usage of the Action-based Input system and XR Interaction Toolkit components. For basic information about the new input system and the XR Interaction Toolkit package, please refer to the Unity documentation.
How the sample works
The sample demonstrates how to interact with UI and other GameObjects in the scene.
The floating UI panel provides common UI elements to interact with, such as a button and a scrollbar. While the buttons are usable with both a gaze pointer and a device pointer, the scrollbar in the sample is only usable with the device pointer. Additionally, another UI element in the scene showcases the input coming from the host controller's touchpad.
Lastly, an interactive cube object can be grabbed with the device pointer, in order to demonstrate 3D object interaction. To make it an interactive object it needs to have the following components:
- Collider
- Rigidbody
- XR Grab Interactable (References the XR Interaction Manager)
![Interactable Object](/assets/images/interactable-object-11119847561649851fbbbe8a7149bd6e.png)
Device Pointer Controller
The device pointer prefab included in the samples is composed of three main components:
- The XR Controller (Action-based) component is responsible for receiving input from an XR input device. In the sample input action references from an action map are assigned to Position, Rotation, Select, Activate and UI Press as seen in the image below.
- The XR Ray Interactor is one of the multiple types of interactors. It can interact with Unity UI elements in the scene as well as valid interactive objects, by using ray casting. The XR Ray Interactor should reference the current XR Interaction Manager in the scene.
- The XR Interactor Line Visual and the corresponding Line Renderer components are used to render a line from the origin of the controller along the controller's forward direction. By default, it is colored red, but once it has hit a valid interactive object it will change color to green.
![XR Controller (Action-based)](/assets/images/action-based-controller-d580e8cf57ac5ff897a64da852e480b5.png)