Last active
March 31, 2018 11:24
-
-
Save kazukitanaka0611/8340b7a6e79841e2dbc3919c0074649b to your computer and use it in GitHub Desktop.
HoloLens Air Tap Create Plane Gaze rotateion
This file contains hidden or 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 UnityEngine; | |
using HoloToolkit.Unity.InputModule; | |
using HoloToolkit.Unity.SpatialMapping; | |
public class TapAndAddWindow : MonoBehaviour, IInputClickHandler | |
{ | |
[SerializeField] | |
GameObject prefab; | |
[SerializeField] | |
float offset = 0f; | |
private void Start() | |
{ | |
InputManager.Instance.AddGlobalListener(gameObject); | |
} | |
public void OnInputClicked(InputClickedEventData eventData) | |
{ | |
RaycastHit hit; | |
if (Physics.Raycast(GazeManager.Instance.GazeOrigin, GazeManager.Instance.GazeNormal, out hit, 30.0f, SpatialMappingManager.Instance.LayerMask)) { | |
var pos = hit.point + hit.normal * offset; | |
var rot = Quaternion.FromToRotation(Vector3.up, hit.normal); | |
Instantiate(prefab, pos, rot); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment