Develop
Develop
Select your platform

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.

Before You Begin

Add a Ray Interactable Component

  1. Open the Unity scene that contains the curved or flat UI prefab you added during the Create a Curved or Flat UI tutorial.
  2. Under Hierarchy, select the UI prefab.
  3. 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
  1. In the Ray Interactable component, set the Pointable Element property to FlatUnityCanvas.
  2. Set the Surface property to Unity Canvas.
Curved Canvas
  1. In the Ray Interactable component, set the Pointable Element property to CurvedUnityCanvas (choose PointableCanvasMesh when prompted).
  2. Set the Surface property to Cylinder.
Scrolling and swiping the UI using a ray interaction
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.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon