Table of Contents

User Interface (UI)

In order to interact with User Interfaces (UI) in VIROO you have to take into account that to interact with this kind of elements in Virtual Reality it is necessary that the components are configured to work in this mode. In this article we are going to cover only this case. This does not mean that it is not possible to interact with these interfaces in desktop mode as well.

Set up the Canvas GameObject

To create a UI we first need to configure a GameObject with the Canvas component from which will hang all the hierarchy of objects that will define the interface (buttons, images...). These are the elements that need to be in that root GameObject.

  • Canvas: Unity´s component. Unlike standard UI canvases in Screen Space, XR Interaction Toolkit requires a World Space Canvas. This positions the UI elements in the 3D world, allowing users to interact with them in VR and Desktop.
  • Tracked Device Graphic Raycaster: This component is crucial for XR Interaction Toolkit UI interaction. It allows controllers (via Ray Interactor) or gaze (via XR Gaze Interactor) to cast rays and detect UI elements in the World Space Canvas.
  • Graphic Raycaster: In order to interact with UI in Desktop mode we need to add this component too.
Tip

If you want to create a UI that does not require interaction, the GraphicRaycaster and TrackedDeviceGraphicRaycaster components are not necessary.

canvas-configuration.png