AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SceneLauncherButton.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 using UnityEngine.SceneManagement;
7 
8 namespace HoloToolkit.Unity
9 {
10  public class SceneLauncherButton : MonoBehaviour, IInputClickHandler
11  {
12  public int SceneIndex { get; set; }
13 
14  public string SceneName
15  {
16  set
17  {
18  gameObject.name = value;
19  textMesh.text = value;
20  }
21  }
22 
23  public Color HighlightedTextColor;
24 
25  public GameObject MenuReference;
26 
27  public bool EnableDebug;
28 
29  private TextMesh textMesh;
30  private Color originalTextColor;
31 
32  private void Awake()
33  {
34  textMesh = GetComponentInChildren<TextMesh>();
35  Debug.Assert(textMesh != null, "SceneLauncherButton must contain a TextMesh.");
36  originalTextColor = textMesh.color;
37  }
38 
39  private void Update()
40  {
41  IsHighlighted = GazeManager.Instance.HitObject == gameObject;
42  }
43 
44  private bool IsHighlighted
45  {
46  set
47  {
48  textMesh.color = value ? HighlightedTextColor : originalTextColor;
49  }
50  }
51 
52  public void OnInputClicked(InputClickedEventData eventData)
53  {
54  if (EnableDebug)
55  {
56  Debug.LogFormat("SceneLauncher: Loading scene {0}: {1}", SceneIndex, SceneManager.GetSceneAt(SceneIndex).name);
57  }
58 
59  MenuReference.SetActive(false);
60  SceneManager.LoadSceneAsync(SceneIndex, LoadSceneMode.Single);
61  }
62  }
63 }
The gaze manager manages everything related to a gaze ray that can interact with other objects...
Definition: GazeManager.cs:13
Interface to implement to react to simple click input.
static T Instance
Returns the Singleton instance of the classes type. If no instance is found, then we search for an in...
Definition: Singleton.cs:26
void OnInputClicked(InputClickedEventData eventData)
Describes an input event that involves a tap.