Ejemplo n.º 1
0
 void fixYesFunc()
 {
     FieldFixPanel.gameObject.SetActive(false);
     MaSangPanel.SetActive(true);
     publicVariable.setIsField(true);
     //MaSangButton.gameObject.SetActive(true);
     GameObject.Find("Plane Generator").SetActive(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            _UpdateApplicationLifecycle();


            if (!publicVariable.getIsField())
            {
                // Hide snackbar when currently tracking at least one plane.
                Session.GetTrackables <DetectedPlane>(m_AllPlanes);
                //bool showSearchingUI = true;
                for (int i = 0; i < m_AllPlanes.Count; i++)
                {
                    if (m_AllPlanes[i].TrackingState == TrackingState.Tracking)
                    {
                        //showSearchingUI = false;
                        break;
                    }
                }

                //SearchingForPlaneUI.SetActive(showSearchingUI);

                // 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;

                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;
                        }

                        // Instantiate Andy model at the hit pose.
                        JangField = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation);

                        // Compensate for the hitPose rotation facing away from the raycast (i.e. camera).
                        JangField.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.
                        JangField.transform.parent = anchor.transform;



                        FieldFixPanel.SetActive(true);
                        publicVariable.setIsField(true);
                    }
                }
            }
        }