Creating feedback for the user

When developing any type of user interface, it's important to provide a system to help guide the experience. In a virtual setting, this is even more important if the user's input method is a Gaze Input.

Without direct input (like a mouse and cursor), we need to create an indirect method which is just as effective. For this project, we'll use a visual glow to indicate when a selectable object is being gazed upon by the user. In the following code snippet, OnPointerEnter and OnPointerExit functions, provided by the EventSystem, will be our feedback mechanism. With these functions, we will add a highlight material and stroke to the selectable GameObject:

  1. Add the following functions after OnPreviewClick():
public void OnPointerEnter (Image image) { 
// when the user's gaze points to image, this statement highlights the gameObject image.material = hilightMaterial; } public void OnPointerExit (Image image) { image.material = null; }

When the pointer (an invisible object directed by the user's gaze) enters the Preview GameObject, OnPointerEnter changes the object's material to hilightMaterial which will be a highlight material set as a public variable. When the pointer leaves the GameObject, the material will be set to none to indicate that the object is no longer clickable.

  1. Save the script.
  2. Validate the changes.
  3. Switch back to Unity, select any preview thumbnail GameObject (that is, Gallery | PreviewHolder | Preview (2)) and note that the Image Selector component in the Inspector window now has four additional value fields; Category Title Name, Category Title, Full Image, and Hilight Material:
Figure 4.2: Public variables in the Image Selector component of a Preview GameObject
..................Content has been hidden....................

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