AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
CycleRotation.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 CycleRotation : CycleArray<Vector3>
15  {
16  [Tooltip("use the local rotation - overrides the UseLocalTransform value of RotateToValue")]
17  public bool UseLocalRotation = false;
18 
19  private RotateToValue mRotation;
20 
21  protected override void Awake()
22  {
23  mRotation = GetComponent<RotateToValue>();
24 
25  base.Awake();
26  }
27 
32  public override void SetIndex(int index)
33  {
34  base.SetIndex(index);
35 
36  // get the rotation and convert it to a Quaternion
37  Vector3 item = Array[Index];
38 
39  Quaternion rotation = Quaternion.identity;
40  rotation.eulerAngles = item;
41 
42  // set the rotation
43  if (mRotation != null)
44  {
45  mRotation.ToLocalTransform = UseLocalRotation;
46  mRotation.TargetValue = rotation;
47  mRotation.StartRunning();
48  }
49  else
50  {
51  if (UseLocalRotation)
52  {
53  TargetObject.transform.localRotation = rotation;
54  }
55  else
56  {
57  TargetObject.transform.rotation = rotation;
58  }
59  }
60  }
61 
62  }
63 }
CycleArray is a class for incrementing through component properties sequentially or assigning specifi...
Definition: CycleArray.cs:15
Sets the rotation (eulerAngles) of an object to the selected value in the array. Add RotateToValue fo...
void StartRunning()
Start the rotation animation
override void SetIndex(int index)
Set the rotation from the Vector3 Euler angles
override void Awake()
set the default TargetObject
animates the rotation of an object with eases