AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SphereGlobalKeywords.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 {
8  public class SphereGlobalKeywords : MonoBehaviour, ISpeechHandler
9  {
10  private Material[] cachedChildMaterials;
11 
12  private void Awake()
13  {
14  Renderer[] childRenderers = GetComponentsInChildren<Renderer>();
15  if (childRenderers != null && childRenderers.Length > 0)
16  {
17  cachedChildMaterials = new Material[childRenderers.Length];
18  for (int i = 0; i < childRenderers.Length; i++)
19  {
20  cachedChildMaterials[i] = childRenderers[i].material;
21  }
22  }
23  }
24 
26  {
27  switch (eventData.RecognizedText.ToLower())
28  {
29  case "reset all":
30  foreach (Material cachedChildMaterial in cachedChildMaterials)
31  {
32  cachedChildMaterial.SetColor("_Color", Color.gray);
33  }
34  break;
35  }
36  }
37 
38  private void OnDestroy()
39  {
40  for (int i = 0; i < cachedChildMaterials.Length; i++)
41  {
42  DestroyImmediate(cachedChildMaterials[i]);
43  }
44  }
45  }
46 }
string RecognizedText
The text that was recognized.
Describes an input event that involves keyword recognition.
Interface to implement to react to speech recognition.