AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
MoveObjectWidget.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 
5 using System.Collections;
6 using System.Collections.Generic;
7 using UnityEngine;
8 namespace HoloToolkit.Examples.InteractiveElements
9 {
13  [RequireComponent(typeof(MoveToPosition))]
15  {
16  [Tooltip("Starting default position")]
17  public Vector3 DefaultPosition;
18 
19  [Tooltip("Target position on focus")]
20  public Vector3 FocusPosition;
21 
22  private MoveToPosition mMoveToPosition;
23 
27  void Awake()
28  {
29  mMoveToPosition = GetComponent<MoveToPosition>();
30 
31  if (mMoveToPosition == null)
32  {
33  Debug.LogError("MoveToPosition:mMoveToPosition is not set in MoveObjectWidget!");
34  Destroy(this);
35  }
36  }
37 
42  public override void SetState(Interactive.ButtonStateEnum state)
43  {
44  base.SetState(state);
45 
46  if (mMoveToPosition != null)
47  {
48  if (state == Interactive.ButtonStateEnum.FocusSelected || state == Interactive.ButtonStateEnum.Focus || state == Interactive.ButtonStateEnum.Press || state == Interactive.ButtonStateEnum.PressSelected)
49  {
50  mMoveToPosition.TargetValue = FocusPosition;
51  mMoveToPosition.StartRunning();
52  }
53  else
54  {
55  mMoveToPosition.TargetValue = DefaultPosition;
56  mMoveToPosition.StartRunning();
57  }
58  }
59  }
60  }
61 }
InteractiveState can exist on a child element of the game object containing the Interactive component...
A position animation component that supports easing and local position The animation can be triggered...
override void SetState(Interactive.ButtonStateEnum state)
Set or animate the position
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
Updates the position of an element based on the Interactive focus state