Guest User

Untitled

a guest
Nov 21st, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.XR.ARFoundation;
  4.  
  5. [RequireComponent(typeof(ARSessionOrigin))]
  6. public class SpawnObject : MonoBehaviour {
  7.  
  8. private ARSessionOrigin origin;
  9. private List<ARRaycastHit> hitResults = new List<ARRaycastHit>();
  10.  
  11. [SerializeField] GameObject prefab;
  12.  
  13. private void Awake()
  14. {
  15. origin = GetComponent<ARSessionOrigin>();
  16. }
  17.  
  18. void Update ()
  19. {
  20. if(Input.GetMouseButtonDown(0)){
  21. if( origin.Raycast(Input.GetTouch(0).position, hitResults))
  22. {
  23. Instantiate(prefab, hitResults[0].pose.position, Quaternion.identity);
  24. }
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment