AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
GazeResponder.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 
6 namespace HoloToolkit.Unity.InputModule.Tests
7 {
12  public class GazeResponder : MonoBehaviour, IFocusable
13  {
14  private Material[] defaultMaterials;
15 
16  private void Start()
17  {
18  defaultMaterials = GetComponent<Renderer>().materials;
19  }
20 
21  public void OnFocusEnter()
22  {
23  for (int i = 0; i < defaultMaterials.Length; i++)
24  {
25  // Highlight the material when gaze enters using the shader property.
26  defaultMaterials[i].SetFloat("_Gloss", 10.0f);
27  }
28  }
29 
30  public void OnFocusExit()
31  {
32  for (int i = 0; i < defaultMaterials.Length; i++)
33  {
34  // Remove highlight on material when gaze exits.
35  defaultMaterials[i].SetFloat("_Gloss", 1.0f);
36  }
37  }
38 
39  private void OnDestroy()
40  {
41  foreach (var material in defaultMaterials)
42  {
43  Destroy(material);
44  }
45  }
46  }
47 }
This class implements IFocusable to respond to gaze changes. It highlights the object being gazed at...
Interface to implement to react to focus enter/exit.
Definition: IFocusable.cs:11