-
-
Save SatoshiRobatoFujimoto/67dfba9c72709790fe1645eafe693030 to your computer and use it in GitHub Desktop.
ガチラボ vol.8
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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using HoloToolkit.Unity.InputModule; | |
public class DrawingManager : MonoBehaviour, ISourceStateHandler, IInputHandler | |
{ | |
IInputSource currentInputSource; | |
private uint id; | |
private bool isDrag = false; | |
public GameObject obj; | |
// Use this for initialization | |
void Start() | |
{ | |
InputManager.Instance.PushFallbackInputHandler(gameObject); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (isDrag) | |
{ | |
Vector3 pos; | |
currentInputSource.TryGetGripPosition(id, out pos); | |
obj.transform.position = pos; | |
} | |
} | |
public void OnInputDown(InputEventData eventData) | |
{ | |
currentInputSource = eventData.InputSource; | |
id = eventData.SourceId; | |
isDrag = true; | |
Debug.Log("Down"); | |
} | |
public void OnInputUp(InputEventData eventData) | |
{ | |
isDrag = false; | |
Debug.Log("Up"); | |
} | |
public void OnSourceDetected(SourceStateEventData eventData) | |
{ | |
Debug.Log("Detected"); | |
} | |
public void OnSourceLost(SourceStateEventData eventData) | |
{ | |
isDrag = false; | |
Debug.Log("Lost"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment