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 Scale : MonoBehaviour, IInputHandler, IManipulationHandler
{
private IInputSource currentInputSource = null;
private uint currentInputSourceId;
private Vector3 currentScale;
public void OnInputDown(InputEventData eventData)
{
currentInputSource = eventData.InputSource;
currentInputSourceId = eventData.SourceId;
currentScale = transform.localScale;
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)
{
Vector3 scale = currentScale * eventData.CumulativeDelta.x + currentScale;
transform.localScale = scale;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment