AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CyclePosition.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 using HoloToolkit.Unity;
7 
8 namespace HoloToolkit.Examples.Prototyping
9 {
14  public class CyclePosition : CycleArray<Vector3>
15  {
16  [Tooltip("use local position instead of position. Overrides MoveToPosition ToLocalPosition setting.")]
17  public bool UseLocalPosition = false;
18 
19  private MoveToPosition mMoveTranslator;
20 
21  protected override void Awake()
22  {
23  mMoveTranslator = GetComponent<MoveToPosition>();
24  base.Awake();
25  }
26 
31  public override void SetIndex(int index)
32  {
33  base.SetIndex(index);
34 
35  Vector3 item = Array[Index];
36 
37  // use MoveTo Position
38  if (mMoveTranslator != null)
39  {
40  mMoveTranslator.ToLocalTransform = UseLocalPosition;
41  mMoveTranslator.TargetValue = item;
42  mMoveTranslator.StartRunning();
43  }
44  else
45  {
46  if (UseLocalPosition)
47  {
48  TargetObject.transform.localPosition = item;
49  }
50  else
51  {
52  TargetObject.transform.position = item;
53  }
54 
55  }
56 
57 
58  }
59 
60  }
61 }
CycleArray is a class for incrementing through component properties sequentially or assigning specifi...
Definition: CycleArray.cs:15
updates the position of an object based on currently selected values from the array. Use MoveToPosition for easing... Auto detected
A position animation component that supports easing and local position The animation can be triggered...
override void SetIndex(int index)
set the position
override void Awake()
set the default TargetObject