Created
October 8, 2017 14:20
-
-
Save nipundavid/6fd92e53f66f9d5e961a0296a5799226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HoloToolkit.Unity.InputModule; | |
using UnityEngine; | |
using IInputHandler = HoloToolkit.Unity.InputModule.IInputHandler; | |
using IManipulationHandler = HoloToolkit.Unity.InputModule.IManipulationHandler; | |
public class Rotate : MonoBehaviour, IInputHandler, IManipulationHandler | |
{ | |
private IInputSource currentInputSource = null; | |
private uint currentInputSourceId; | |
public void OnInputDown(InputEventData eventData) | |
{ | |
currentInputSource = eventData.InputSource; | |
currentInputSourceId = eventData.SourceId; | |
InputManager.Instance.PushModalInputHandler(gameObject); | |
InputManager.Instance.RaiseManipulationStarted(currentInputSource, currentInputSourceId, transform.position); | |
} | |
public void OnInputUp(InputEventData eventData) | |
{ | |
InputManager.Instance.RaiseManipulationCompleted(currentInputSource, currentInputSourceId, transform.position); | |
InputManager.Instance.PopModalInputHandler(); | |
} | |
public void OnManipulationCanceled(ManipulationEventData eventData) | |
{ | |
} | |
public void OnManipulationCompleted(ManipulationEventData eventData) | |
{ | |
} | |
public void OnManipulationStarted(ManipulationEventData eventData) | |
{ | |
} | |
public void OnManipulationUpdated(ManipulationEventData eventData) | |
{ | |
float multiplier = 1.0f; | |
float cameraLocalYRotation = Camera.main.transform.localRotation.eulerAngles.y; | |
if (cameraLocalYRotation > 270 || cameraLocalYRotation < 90) | |
multiplier = -1.0f; | |
var rotation = new Vector3(0, eventData.CumulativeDelta.x * multiplier); | |
transform.Rotate(rotation * 10, Space.World); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment