Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.XR.ARFoundation;
- [RequireComponent(typeof(ARSessionOrigin))]
- public class SpawnObject : MonoBehaviour {
- private ARSessionOrigin origin;
- private List<ARRaycastHit> hitResults = new List<ARRaycastHit>();
- [SerializeField] GameObject prefab;
- private void Awake()
- {
- origin = GetComponent<ARSessionOrigin>();
- }
- void Update ()
- {
- if(Input.GetMouseButtonDown(0)){
- if( origin.Raycast(Input.GetTouch(0).position, hitResults))
- {
- Instantiate(prefab, hitResults[0].pose.position, Quaternion.identity);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment