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:
- Double-click the ImageSelector script in the Project/Scripts directory to open it in the default editor.
- 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 ...