Facilitating user interaction
Unity provides various components for facilitating user input. These components are used first to identify if the user is looking at a specific GameObject, if the user has interacted with a touch device, and how a GameObject should respond to input from a touch device. Let's take a brief look at the components we need for this project.
Raycasters
When we created the first Canvas for the scene, Unity also added an item called EventSystem
. An EventSystem
is used to detect where current input events need to be sent and Raycasters provide that information. Think of a Raycaster as a visible laser pointer. When evoked in your scene, the Raycaster sends out a ray which reports the object or objects it has collided with. For our project, we will be using a Graphic Raycaster, but there are also two other types of Raycasters to consider:
- Graphic Raycaster: Queries all UI elements in a canvas to determine if any item collides with the ray. This type also has a few properties...