AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CycleText.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 System.Collections;
5 using System.Collections.Generic;
6 using UnityEngine;
7 using UnityEngine.UI;
8 
9 namespace HoloToolkit.Examples.Prototyping
10 {
14  public class CycleText : CycleArray<string>
15  {
16  private TextMesh mTextMesh;
17  private Text mText;
18 
19  protected override void Awake()
20  {
21  base.Awake();
22 
23  mTextMesh = GetComponent<TextMesh>();
24  mText = GetComponent<Text>();
25 
26  if (mTextMesh == null && mText == null)
27  {
28  Debug.LogError("TextMesh or Text is not set in CycleText!");
29  Destroy(this);
30  }
31  }
32 
37  public override void SetIndex(int index)
38  {
39  base.SetIndex(index);
40 
41  if (mTextMesh != null)
42  {
43  mTextMesh.text = Array[index];
44  }
45 
46  if (mText != null)
47  {
48  mText.text = Array[index];
49  }
50 
51  }
52  }
53 }
CycleArray is a class for incrementing through component properties sequentially or assigning specifi...
Definition: CycleArray.cs:15
override void Awake()
set the default TargetObject
Definition: CycleText.cs:19
Sets the text value of a TextMesh or UI Text object based on the selected value of the array ...
Definition: CycleText.cs:14
override void SetIndex(int index)
Set the text...
Definition: CycleText.cs:37