public override void Update() { TouchEntity entity = TouchHandler.Pop(); if (0 == entity.touchPositionList.Count || TouchPhase.Began != entity.touchPhase) { return; } Vector3 touchPosition = entity.touchPositionList[0]; Vector3 viewportPoint = Camera.main.ScreenToViewportPoint(touchPosition); ARPoint point = new ARPoint(); point.x = viewportPoint.x; point.y = viewportPoint.y; UnityARSessionNativeInterface nativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface(); List <ARHitTestResult> hitResultList = nativeInterface.HitTest(point, ARHitTestResultType.ARHitTestResultTypeExistingPlaneUsingExtent); if (0 == hitResultList.Count) { return; } else { Notifier notifier = Notifier.GetInstance(); notifier.Notify(NotifyMessage.OnRaycastHit); } return; }
public override void Update() { base.Update(); TouchEntity entity = TouchHandler.Pop(); if (0 == entity.touchPositionList.Count || TouchPhase.Began != entity.touchPhase) { return; } Vector3 touchPosition = entity.touchPositionList[0]; TrackableHit hit; TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | TrackableHitFlags.FeaturePointWithSurfaceNormal; if (false == Frame.Raycast(touchPosition.x, touchPosition.y, raycastFilter, out hit)) { return; } Vector3 lhs = UnityEngine.Camera.main.transform.position - hit.Pose.position; Vector3 rhs = hit.Pose.rotation * Vector3.up; float dot = Vector3.Dot(lhs, rhs); if (false == (false != (hit.Trackable is DetectedPlane) && dot < 0)) { Notifier notifier = Notifier.GetInstance(); notifier.Notify(NotifyMessage.OnRaycastHit); } return; }