AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
LabelSwapWidget.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 
8 namespace HoloToolkit.Examples.InteractiveElements
9 {
14  {
15  [Tooltip("string for the default state")]
16  public string DefaultLabel;
17 
18  [Tooltip("string for the selected state")]
19  public string SelectedLabel;
20 
21  public TextMesh Label;
22 
26  private void Awake()
27  {
28  if (Label == null)
29  {
30  Label = GetComponent<TextMesh>();
31  }
32 
33  if (Label == null)
34  {
35  Debug.LogError("Textmesh:Label is not set in LabelSwapWidget!");
36  Destroy(this);
37  }
38  }
39 
44  public override void SetState(Interactive.ButtonStateEnum state)
45  {
46  base.SetState(state);
47 
48  string label = "";
49  if (state == Interactive.ButtonStateEnum.FocusSelected || state == Interactive.ButtonStateEnum.Selected || state == Interactive.ButtonStateEnum.PressSelected || state == Interactive.ButtonStateEnum.DisabledSelected)
50  {
51  label = SelectedLabel;
52  }
53  else
54  {
55  label = DefaultLabel;
56  }
57 
58  Label.text = label;
59 
60  }
61  }
62 }
InteractiveState can exist on a child element of the game object containing the Interactive component...
Swaps the text in the TextMesh based on Interactive state, like "On" and "Off"
ButtonStateEnum
A button typically has 8 potential states. We can update visual feedback based on state change...
Definition: Interactive.cs:80
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22
override void SetState(Interactive.ButtonStateEnum state)
Set the text value