AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ButtonThemeWidgetOutline.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;
7 using System;
8 
9 namespace HoloToolkit.Examples.InteractiveElements
10 {
16  {
17  [Tooltip("Button inner material")]
18  public Material InnerMaterial;
19 
20  [Tooltip("Button outer material")]
21  public Material OuterMaterial;
22 
23  [Tooltip("tag for the color theme for the inner material")]
24  public string InnerColorThemeTag = "innerColorDefault";
25 
26  [Tooltip("tag for the color theme for the outer material")]
27  public string OuterColorThemeTag = "outerColorDefault";
28 
29  [Tooltip("A color tween component : required, but could be on a different object")]
31 
32  private ColorInteractiveTheme mInnerColorTheme;
33  private ColorInteractiveTheme mOuterColorTheme;
34 
35  private string mCheckInnerColorThemeTag = "";
36  private string mCheckOuterColorThemeTag = "";
37 
41  private void Awake()
42  {
43  if (ColorBlender == null)
44  {
45  ColorBlender = GetComponent<ColorTransition>();
46  }
47 
48  if (ColorBlender == null)
49  {
50  Debug.LogError("ColorBlender is not on the gameObject: " + name);
51  Destroy(this);
52  }
53  }
54 
58  private void Start()
59  {
60  SetTheme();
61  RefreshIfNeeded();
62  }
63 
64  public override void SetTheme()
65  {
66  if (InnerColorThemeTag != "")
67  {
68  mInnerColorTheme = GetColorTheme(InnerColorThemeTag);
69  mCheckInnerColorThemeTag = InnerColorThemeTag;
70  }
71 
72  if (OuterColorThemeTag != "")
73  {
74  mOuterColorTheme = GetColorTheme(OuterColorThemeTag);
75  mCheckOuterColorThemeTag = OuterColorThemeTag;
76  }
77  }
78 
83  public override void SetState(Interactive.ButtonStateEnum state)
84  {
85  base.SetState(state);
86 
87  if (mInnerColorTheme != null)
88  {
89  ColorBlender.StartTransition(mInnerColorTheme.GetThemeValue(state), InnerMaterial.name);
90  }
91 
92  if (mOuterColorTheme != null)
93  {
94  ColorBlender.StartTransition(mOuterColorTheme.GetThemeValue(state), OuterMaterial.name);
95  }
96  }
97 
98  private void Update()
99  {
100  if (!mCheckOuterColorThemeTag.Equals(OuterColorThemeTag) || !mCheckInnerColorThemeTag.Equals(InnerColorThemeTag))
101  {
102  SetTheme();
103  RefreshIfNeeded();
104  }
105  }
106  }
107 }
Type GetThemeValue(Interactive.ButtonStateEnum state)
ButtonStateEnum
A button typically has 8 potential states. We can update visual feedback based on state change...
Definition: Interactive.cs:80
A version of InteractiveWidget that uses an InteractiveTheme to define each state ...
updates the button colors based on the button theme handles two materials
void StartTransition(Color color, string name="")
Fades the color of a material called by name
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22
A color blending animation component, handles multiple materials
override void SetTheme()
Sets the themes based on the Theme Tags
override void SetState(Interactive.ButtonStateEnum state)
set the colors