AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ScaleThemeWidget.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 {
15  {
16  [Tooltip("A tag for finding the theme in the scene")]
17  public string ThemeTag = "defaultScale";
18 
19  [Tooltip("Scale to Value component for animating scale")]
21 
22  private Vector3InteractiveTheme mScaleTheme;
23  private Material mMaterial;
24 
25  private string mCheckThemeTag = "";
26 
30  private void Awake()
31  {
32  if (ScaleTweener == null)
33  {
34  ScaleTweener = GetComponent<ScaleToValue>();
35  }
36  }
37 
41  private void Start()
42  {
43  if (mScaleTheme == null)
44  {
45  SetTheme();
46  }
47 
48  RefreshIfNeeded();
49  }
50 
51  public override void SetTheme()
52  {
53  mScaleTheme = GetVector3Theme(ThemeTag);
54  mCheckThemeTag = ThemeTag;
55  }
56 
61  public override void SetState(Interactive.ButtonStateEnum state)
62  {
63  base.SetState(state);
64 
65  if (mScaleTheme != null)
66  {
67  if (ScaleTweener != null)
68  {
69  ScaleTweener.TargetValue = mScaleTheme.GetThemeValue(state);
70  ScaleTweener.StartRunning();
71  }
72  else
73  {
74  transform.localScale = mScaleTheme.GetThemeValue(state);
75  }
76  }
77  }
78 
79  private void Update()
80  {
81  if (!mCheckThemeTag.Equals(ThemeTag))
82  {
83  SetTheme();
84  RefreshIfNeeded();
85  }
86  }
87  }
88 }
void StartRunning()
Start the animation
Definition: ScaleToValue.cs:66
Animates the scaling of an object with eases
Definition: ScaleToValue.cs:14
Type GetThemeValue(Interactive.ButtonStateEnum state)
override void SetTheme()
Sets the themes based on the Theme Tags
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 ...
override void SetState(Interactive.ButtonStateEnum state)
Set the Scale
updates the button scale based on the button theme
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22