AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
PositionThemeWidget.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 = "defaultPosition";
18 
19  [Tooltip("Move to Position, a component for animating position")]
21 
22  private Vector3InteractiveTheme mPositionTheme;
23 
24  private string mCheckThemeTag = "";
25 
29  private void Awake()
30  {
31  if (MovePositionTweener == null)
32  {
33  MovePositionTweener = GetComponent<MoveToPosition>();
34  }
35  }
36 
40  private void Start()
41  {
42  if (mPositionTheme == null)
43  {
44  SetTheme();
45  }
46 
47  RefreshIfNeeded();
48  }
49 
50  public override void SetTheme()
51  {
52  mPositionTheme = GetVector3Theme(ThemeTag);
53  mCheckThemeTag = ThemeTag;
54  }
55 
60  public override void SetState(Interactive.ButtonStateEnum state)
61  {
62  base.SetState(state);
63 
64  if (mPositionTheme != null)
65  {
66  if (MovePositionTweener != null)
67  {
68  MovePositionTweener.TargetValue = mPositionTheme.GetThemeValue(state);
69  MovePositionTweener.StartRunning();
70  }
71  else
72  {
73  transform.localPosition = mPositionTheme.GetThemeValue(state);
74  }
75  }
76  }
77 
78  private void Update()
79  {
80  if (!mCheckThemeTag.Equals(ThemeTag))
81  {
82  SetTheme();
83  RefreshIfNeeded();
84  }
85  }
86  }
87 }
Type GetThemeValue(Interactive.ButtonStateEnum state)
A position animation component that supports easing and local position The animation can be triggered...
updates the button position based on the button theme
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 position
override void SetTheme()
Sets the themes based on the Theme Tags
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22