AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SphereKeywords.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  [RequireComponent(typeof(Renderer))]
9  public class SphereKeywords : MonoBehaviour, ISpeechHandler
10  {
11  private Material cachedMaterial;
12  private Color defaultColor;
13 
14  private void Awake()
15  {
16  cachedMaterial = GetComponent<Renderer>().material;
17  defaultColor = cachedMaterial.color;
18  }
19 
20  public void ChangeColor(string color)
21  {
22  switch (color.ToLower())
23  {
24  case "red":
25  cachedMaterial.SetColor("_Color", Color.red);
26  break;
27  case "blue":
28  cachedMaterial.SetColor("_Color", Color.blue);
29  break;
30  case "green":
31  cachedMaterial.SetColor("_Color", Color.green);
32  break;
33  }
34  }
35 
36  public void ResetColor()
37  {
38  cachedMaterial.SetColor("_Color", defaultColor);
39  }
40 
42  {
43  ChangeColor(eventData.RecognizedText);
44  }
45 
46  private void OnDestroy()
47  {
48  DestroyImmediate(cachedMaterial);
49  }
50  }
51 }
void OnSpeechKeywordRecognized(SpeechEventData eventData)
string RecognizedText
The text that was recognized.
Describes an input event that involves keyword recognition.
Interface to implement to react to speech recognition.