AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
GestureControlTest.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 
8 namespace HoloToolkit.Examples.InteractiveElements
9 {
14  {
15 
16  public GameObject EffectDot;
17  public Color[] EffectColors;
19  public float FeebackVisualDistance = 0.95f;
20 
21  private Renderer mEffectRenderer;
22  private bool mHasGaze = false;
23 
24  private float mTickerTime = 0.5f;
25  private float mTickerCount = 0;
26 
27  private void Start()
28  {
29  mEffectRenderer = EffectDot.GetComponent<Renderer>();
30  mTickerCount = mTickerTime;
31  }
32 
41  public override void ManipulationUpdate(Vector3 startVector, Vector3 currentVector, Vector3 startOrigin, Vector3 startRay, GestureInteractive.GestureManipulationState gestureState)
42  {
43  base.ManipulationUpdate(startVector, currentVector, startOrigin, startRay, gestureState);
44 
45  Vector3 mDirection = DirectionVector.normalized;
46 
47  if (gestureState == GestureInteractive.GestureManipulationState.Start)
48  {
49  mTickerCount = mTickerTime;
50 
51  mEffectRenderer.material.color = EffectColors[1];
52  }
53 
54  if (gestureState == GestureInteractive.GestureManipulationState.None)
55  {
56  mTickerCount = 0;
57 
58  mEffectRenderer.material.color = EffectColors[0];
59  }
60 
61  EffectDot.transform.localPosition = mDirection * FeebackVisualDistance * CurrentPercentage;
62  }
63 
68  private void TickerUpdate(float percent)
69  {
70  EffectDot.transform.localPosition = Vector3.Lerp(EffectDot.transform.localPosition, Vector3.zero, percent);
71  }
72 
76  protected override void Update()
77  {
78  if (mHasGaze != Button.HasGaze)
79  {
80  EffectDot.SetActive(Button.HasGaze);
81  mHasGaze = Button.HasGaze;
82  }
83 
84  if (mTickerCount < mTickerTime)
85  {
86  mTickerCount += Time.deltaTime;
87  if (mTickerCount > mTickerTime)
88  {
89  mTickerCount = mTickerTime;
90  }
91 
92  TickerUpdate(mTickerCount / mTickerTime);
93  }
94  }
95  }
96 }
override void ManipulationUpdate(Vector3 startVector, Vector3 currentVector, Vector3 startOrigin, Vector3 startRay, GestureInteractive.GestureManipulationState gestureState)
provide visual feedback based on state and update element position
GestureInteractive extends Interactive and handles more advanced gesture events. On Press a gesture b...
override void Update()
Update visuals based on gaze and power the ticker
A sample GestureInteractiveControl that moves and element in space using raw gesture data ...
bool HasGaze
Does the GameObject currently have focus?
Definition: Interactive.cs:35
Interactive exposes basic button type events to the Unity Editor and receives messages from the Gestu...
Definition: Interactive.cs:22