Created
October 10, 2017 15:46
-
-
Save nipundavid/8c5a228e0e217a3d9cc2e2df22f3ab89 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 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