AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
InteractiveWidgetTest.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 
7 namespace HoloToolkit.Examples.InteractiveElements
8 {
13  {
14  public Color[] EffectColors;
15  public Vector3[] EffectScale;
16  public Vector3[] EffectPosition;
17 
18  private Renderer mRenderer;
19 
20  private void Start()
21  {
22  mRenderer = this.gameObject.GetComponent<Renderer>();
23  }
38  public override void SetState(Interactive.ButtonStateEnum state)
39  {
40  int colorIndex = -1;
41  switch (state)
42  {
43  case Interactive.ButtonStateEnum.Default:
44  this.gameObject.transform.localScale = EffectScale[0];
45  this.gameObject.transform.localPosition = EffectPosition[0];
46  colorIndex = 0;
47  break;
48  case Interactive.ButtonStateEnum.Focus:
49  this.gameObject.transform.localScale = EffectScale[1];
50  this.gameObject.transform.localPosition = EffectPosition[0];
51  colorIndex = 0;
52  break;
53  case Interactive.ButtonStateEnum.Press:
54  this.gameObject.transform.localPosition = EffectPosition[1];
55  colorIndex = 0;
56  break;
57  case Interactive.ButtonStateEnum.Selected:
58  this.gameObject.transform.localScale = EffectScale[0];
59  this.gameObject.transform.localPosition = EffectPosition[0];
60  colorIndex = 1;
61  break;
62  case Interactive.ButtonStateEnum.FocusSelected:
63  this.gameObject.transform.localScale = EffectScale[1];
64  this.gameObject.transform.localPosition = EffectPosition[0];
65  colorIndex = 1;
66  break;
67  case Interactive.ButtonStateEnum.PressSelected:
68  this.gameObject.transform.localPosition = EffectPosition[1];
69  colorIndex = 1;
70  break;
71  case Interactive.ButtonStateEnum.Disabled:
72  this.gameObject.transform.localScale = EffectScale[0];
73  this.gameObject.transform.localPosition = EffectPosition[0];
74  colorIndex = 0;
75  break;
76  case Interactive.ButtonStateEnum.DisabledSelected:
77  this.gameObject.transform.localScale = EffectScale[0];
78  this.gameObject.transform.localPosition = EffectPosition[0];
79  colorIndex = 1;
80  break;
81  default:
82  break;
83  }
84 
85  if (mRenderer != null && colorIndex > -1)
86  {
87  mRenderer.material.color = EffectColors[colorIndex];
88  }
89  }
90  }
91 }
InteractiveState can exist on a child element of the game object containing the Interactive component...
ButtonStateEnum
A button typically has 8 potential states. We can update visual feedback based on state change...
Definition: Interactive.cs:80
Sample Interactive Widget for changing colors and updating positions based on ButtonStateEnum ...
override void SetState(Interactive.ButtonStateEnum state)
Interactive calls this method on state change
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22