Image selector

The ImageSelector script will use GetMouseButtonDown and a Graphic Raycaster to determine if the user has selected one of the Preview GameObjects. If these two events are simultaneously true, then the image associated with the Preview GameObject will be assigned to the FullImage GameObject. In the following steps, we'll create the ImageSelector script, which will then be applied to the Preview GameObjects:

  1. Double-click the ImageSelector script in the Project/Scripts directory to open it in the default editor.
  2. The first step is to let Unity know what components are going to be used in the script. Since we'll be checking to see if the Raycaster collides with a UI element, we'll need the UnityEngine.UI and UnityEngine.EventSystems ...

Get Virtual Reality Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.