AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
NavigationRotateResponder.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 System;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.InputModule.Tests
8 {
14  public class NavigationRotateResponder : MonoBehaviour, INavigationHandler
15  {
16  [Tooltip("Rotation sensitivity controls the amount of rotation.")]
17  public float RotationSensitivity = 10.0f;
18 
19  private float rotationFactor = 0.0f;
20  private Vector3 navigationDelta = Vector3.zero;
21 
22  private void Update()
23  {
24  PerformRotation();
25  }
26 
27  private void PerformRotation()
28  {
29  if (navigationDelta == Vector3.zero)
30  {
31  return;
32  }
33 
34  // This will help control the amount of rotation.
35  // Taking the delta along the horizontal axis movement.
36  rotationFactor = navigationDelta.x * RotationSensitivity;
37 
38  // Rotate object along the Y axis using.
39  transform.Rotate(new Vector3(0, -1 * rotationFactor, 0));
40  }
41 
43  {
44  navigationDelta = Vector3.zero;
45  InputManager.Instance.OverrideFocusedObject = null;
46  }
47 
49  {
50  navigationDelta = Vector3.zero;
51  InputManager.Instance.OverrideFocusedObject = null;
52  }
53 
55  {
56  InputManager.Instance.OverrideFocusedObject = gameObject;
57  navigationDelta = eventData.NormalizedOffset;
58  }
59 
61  {
62  navigationDelta = eventData.NormalizedOffset;
63  }
64  }
65 }
Input Manager is responsible for managing input sources and dispatching relevant events to the approp...
Definition: InputManager.cs:19
Interface to implement to react to navigation gestures.
This is an example of how to use navigation gesture for a continuous rotation response. This class implements the INavigationHandler interface. It rotates the object along the Y axis ready the navigation X values.
static T Instance
Returns the Singleton instance of the classes type. If no instance is found, then we search for an in...
Definition: Singleton.cs:26
Describes an input event that involves content navigation.
Vector3 NormalizedOffset
The amount of manipulation that has occurred. Sent in the form of a normalized offset of a hand...