AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CycleStatusDisplay.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 System.Collections;
6 using UnityEngine.UI;
7 
8 namespace HoloToolkit.Examples.Prototyping
9 {
14  public class CycleStatusDisplay : MonoBehaviour
15  {
16  [Tooltip("A GameObject containing a component that implements ICycle")]
17  public GameObject CycleHost;
18 
19  private ICycle mCycleHost;
20  private TextMesh mTextMesh;
21  private Text mText;
22 
23  // Use this for initialization
24  void Awake()
25  {
26  if(CycleHost == null)
27  {
28  CycleHost = this.gameObject;
29  Debug.Log("CycleHost was set to self by default");
30  }
31 
32  mTextMesh = GetComponent<TextMesh>();
33  mText = GetComponent<Text>();
34 
35  if (mTextMesh == null && mText == null)
36  {
37  Debug.LogError("There are no Text Components on this <GameObject:" + this.gameObject.name + ">");
38  }
39 
40  mCycleHost = CycleHost.GetComponent<ICycle>();
41  }
42 
46  void Update()
47  {
48  if (mTextMesh != null && mCycleHost != null)
49  {
50  mTextMesh.text = (mCycleHost.Index + 1) + "/" + (mCycleHost.GetLastIndex() + 1);
51  }
52 
53  if (mText != null && mCycleHost != null)
54  {
55  mText.text = (mCycleHost.Index + 1) + "/" + (mCycleHost.GetLastIndex() + 1);
56  }
57  }
58  }
59 
60 }
An interface for components that cycle through an array of properties. A component can be built to cy...
Definition: ICycle.cs:13
CycleStatusDisplay shows the current index and array length (i/l) of a CycleBase component Works with...
int GetLastIndex()
Retrieve the last index of the array.