Using Event Triggers for user feedback

Feedback is extremely important in every aspect of successful interactions. VR is no different. In Unity's Editor, it is very simple to select a thumbnail, because we have a visual pointing device (mouse), which makes the selection easy. In this VR environment, we do not have such a device, but we can still provide feedback to help guide the user.

The following steps will outline how to using Event Triggers to detect when the user’s gaze has entered or left a thumbnail preview GameObject:

  1. Select Preview (1) in the first PreviewHolder GameObject. Unfortunately, this operation can not be completed on multiple GameObjects at once.
  2. Click on Add Component in the Inspector window and clear the search field.
  3. Navigate to Event | Event Trigger and apply it to Preview (1).
  4. Click on the Add New Event Type button and choose select PointerEnter. This will create an empty Pointer Enter trigger list.
  5. Click on the Plus symbol in the lower-right corner of the empty list to add a function to the empty list.
  6. Drag the currently selected object, Preview (1), from the Hierarchy window to replace the None (Object) value. By doing this, we are identifying Preview (1) as the object we want to manipulate.
  7. The drop-down window with no function will be highlighted. Select navigate to ImageSelector | OnPointerEnter (Image) to assign the function.
  8. Next, set the image value by dragging the Image (Script) component from higher up in the Inspector window to replace the None (Image) value. The value will change to Preview (1) (Image).

Test  the change by clicking on the Play button to run the scene. While the scene is running, hover your cursor over the Preview (1) GameObject. Notice that it will now highlight as we defined in the script. However, it doesn't switch back to its default texture of none. So, we will add a new trigger to provide that feature:

  1. Select the same Preview (1) GameObject.
  2. Then, click on Add New Event Type under the Event Trigger component and choose PointerExit. The new event will be populated with the same values as the Pointer Enter event.
  3. Change the drop-down function menu to ImageSelector | OnPointerExit(Image).
  4. Hit click on Play and test the event by hovering over the thumbnail with the mouse cursor.
  5. Complete the feedback feature by adding these Event Triggers to each of the Preview (x) GameObjects.
  6. Save the scene and Unity project.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.88.212