터치하면
public GameObject ObjPrefab;
할당해놓은 오브젝트가 anchor 위치로 이동함.
Anchor.cs 열어보면 Anchor가 트레킹 되지않을경우 child Object들은 setActive를 끄는 부분이 존재함. 주의
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | public void Update() { _UpdateApplicationLifecycle(); Touch touch; if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) { return; } if (EventSystem.current.IsPointerOverGameObject(touch.fingerId)) { return; } TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | TrackableHitFlags.FeaturePointWithSurfaceNormal; if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out TrackableHit hit)) { if ((hit.Trackable is DetectedPlane) && Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position, hit.Pose.rotation * Vector3.up) < 0) { Debug.Log("Hit at back of the current DetectedPlane"); } else { //GameObject prefab; if (hit.Trackable is FeaturePoint) return; var anchor = hit.Trackable.CreateAnchor(hit.Pose); ObjPrefab.transform.parent = anchor.transform; Vector3 l_euler = FirstPersonCamera.transform.rotation.eulerAngles; l_euler = new Vector3(0f, l_euler.y, 0f); ObjPrefab.transform.rotation = Quaternion.Euler(l_euler); ObjPrefab.transform.localPosition = new Vector3(0f, 1f, 0f); } } } |