Last active
September 28, 2020 11:01
-
-
Save hackertron/e9360c8ff61b5bdcccc87f47f8da8d8d to your computer and use it in GitHub Desktop.
InputController script
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 UnityEngine.XR.ARFoundation; | |
public class InputManager : MonoBehaviour | |
{ | |
public GameObject AR_object; | |
public Camera AR_Camera; | |
public ARRaycastManager raycastManager; | |
public List<ARRaycastHit> hits = new List<ARRaycastHit>(); | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if(Input.GetMouseButtonDown(0)) | |
{ | |
Ray ray = AR_Camera.ScreenPointToRay(Input.mousePosition); | |
if(raycastManager.Raycast(ray, hits)) | |
{ | |
Pose pose = hits[0].pose; | |
Instantiate(AR_object, pose.position, pose.rotation); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment