// in ScoreboardController.cs
    void CreateAnchor()
    {
        // Create the position of the anchor by raycasting a point towards
        // the top of the screen.
        Vector2 pos            = new Vector2(Screen.width * .5f, Screen.height * .90f);
        Ray     ray            = firstPersonCamera.ScreenPointToRay(pos);
        Vector3 anchorPosition = ray.GetPoint(5f);

        StartCoroutine(CodelabUtils.Toast(
                           "Pos vec2: " + pos + " anchor pos vec3: " + anchorPosition, 5));

        // Create the anchor at that point.
        if (anchor != null)
        {
            DestroyObject(anchor);
        }
        anchor = detectedPlane.CreateAnchor(
            new Pose(anchorPosition, Quaternion.identity));

        // Attach the scoreboard to the anchor.
        transform.position = anchorPosition;
        transform.SetParent(anchor.transform);

        // Record the y offset from the plane.
        yOffset = transform.position.y - detectedPlane.CenterPose.position.y;

        // Finally, enable the renderers.
        foreach (Renderer r in GetComponentsInChildren <Renderer>())
        {
            r.enabled = true;
        }
    }
示例#2
0
 void SetSelectedPlane(DetectedPlane selectedPlane)
 {
     //Debug.Log("Selected plane centered at " + selectedPlane.CenterPose.position);
     StartCoroutine(CodelabUtils.Toast(
                        "Selected plane centered at " + selectedPlane.CenterPose.position, 5));
     scoreboard.SetSelectedPlane(selectedPlane);
     snakeController.SetPlane(selectedPlane);
 }
示例#3
0
 void QuitOnConnectionErrors()
 {
     if (Session.Status == SessionStatus.ErrorPermissionNotGranted)
     {
         StartCoroutine(CodelabUtils.ToastAndExit(
                            "Camera permission is needed to run this application.", 5));
     }
     else if (Session.Status.IsError())
     {
         // This covers a variety of errors.  See reference for details
         // https://developers.google.com/ar/reference/unity/namespace/GoogleARCore
         StartCoroutine(CodelabUtils.ToastAndExit(
                            "ARCore encountered a problem connecting. Please restart the app.", 5));
     }
     else
     {
         StartCoroutine(CodelabUtils.Toast(
                            "This device is rdy for run ARCore", 5));
     }
 }