SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1008 B

4 years ago
  1. using UnityEngine;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine.XR.ARFoundation;
  6. [RequireComponent(typeof(ARRaycastManager))]
  7. public class Selection__1 : MonoBehaviour
  8. {
  9. public GameObject placePrefab;
  10. private ARRaycastManager aRRaycastManager;
  11. private static List<ARRaycastHit> hits = new List<ARRaycastHit>();
  12. private void Awake()
  13. {
  14. aRRaycastManager = GetComponent<ARRaycastManager>();
  15. }
  16. private void Update()
  17. {
  18. if (Input.touchCount > 0)
  19. {
  20. Touch touch = Input.GetTouch(0);
  21. if (touch.phase == TouchPhase.Began)
  22. {
  23. var touchPostion = touch.position;
  24. if (aRRaycastManager.Raycast(touchPostion, hits, UnityEngine.XR.ARSubsystems.TrackableType.Planes)){
  25. var hitPose = hits[0].pose;
  26. Instantiate(placePrefab, hitPose.position, hitPose.rotation);
  27. }
  28. }
  29. }
  30. }
  31. }