Instantly share code, notes, and snippets.

Embed
What would you like to do?
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