/// <summary> /// The Unity Update() method. /// </summary> public void Update() { _UpdateApplicationLifecycle(); // If the player has not touched the screen, we are done with this update. Touch touch; if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began) //клик по экрану { return; } // Raycast against the location the player touched to search for planes. TrackableHit hit; TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon | TrackableHitFlags.FeaturePointWithSurfaceNormal; //TODO: add image saving from https://stackoverflow.com/questions/49579334/save-acquirecameraimagebytes-from-unity-arcore-to-storage-as-an-image if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit)) { // Use hit pose and camera pose to check if hittest is from the // back of the plane, if it is, no need to create the anchor. 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 { // Choose the Andy model for the Trackable that got hit. //GameObject prefab; //if (hit.Trackable is FeaturePoint) //{ // prefab = AndyPointPrefab; //} //else //{ // prefab = AndyPlanePrefab; //} GameObject prefab = Resources.Load <GameObject>(canvasS.GetPathToPrefub()); // Instantiate Andy model at the hit pose. var andyObject = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation); // Compensate for the hitPose rotation facing away from the raycast (i.e. camera). andyObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self); // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical // world evolves. var anchor = hit.Trackable.CreateAnchor(hit.Pose); // Make Andy model a child of the anchor. andyObject.transform.parent = anchor.transform; //TakeImage(); using (var image = Frame.CameraImage.AcquireCameraImageBytes()) { if (!image.IsAvailable) { return; } _OnImageAvailable(image.Width, image.Height, image.YRowStride, image.Y, 0); } } } }