Use a Ray Interaction with a UI
By default, the UI prefabs described in
Create a Curved or Flat UI support the
Poke interaction. However, poking only works for UIs that you can physically reach. In this tutorial, you learn how to use a ray interactable to interact with a UI that is out of reach. To try ray interactions in a pre-built scene, see the
RayExamples scene.
Add a Ray Interactable Component
Under Hierarchy, select the UI prefab.
Under Inspector, add a Ray Interactable component by clicking the Add Component button and searching for Ray Interactable.
Set the Pointable Element
In order for the canvas to detect when you’re hovering or selecting it, you have to set the canvas as the pointable element.
Flat Canvas
In the Ray Interactable component, set the Pointable Element property to FlatUnityCanvas.
Set the Surface property to Unity Canvas.
Curved Canvas
In the Ray Interactable component, set the Pointable Element property to CurvedUnityCanvas (choose PointableCanvasMesh when prompted).
Set the Surface property to Cylinder.
Using a ray interaction to interact with a curved canvas and a flat canvas.
Note
To share a cylinder between multiple canvases, see the RayExamples scene.