使用 ArCore 显示 Debug.drawLine()

Display Debug.drawLine() with ArCore

我正在尝试在我使用 ARCore 实例化的两个对象之间显示一条线。我在虚拟环境(没有 ARCORE)中没有任何问题,但是当我想将其调整为增强现实时,我的标记显示但不是我的线。我也在努力调试它,因为我没有任何关于 phone...

的日志

我的代码:

  // Raycast against the location the player touched to search for planes.
        TrackableHit hit;
        TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinBounds | TrackableHitFlags.PlaneWithinPolygon;

        if (Session.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
        {
            if (instantiationState == true) //instantiate greencube on click
            {
                Destroy(landmarkEven);
                andyObject = Instantiate(Resources.Load("CubeA", typeof(GameObject)), (hit.Pose.position + new Vector3(0, 1, 0)), hit.Pose.rotation) as GameObject;
                landmarkEven = andyObject;
                instantiationState = false;

            }
            else //instantiate redcube on click
            {
                Destroy(landmarkOdd);
                andyObject = Instantiate(Resources.Load("CubeB", typeof(GameObject)), (hit.Pose.position + new Vector3(0, 1, 0)), hit.Pose.rotation) as GameObject;
                landmarkOdd = andyObject;
                instantiationState = true;
            }

            // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
            // world evolves.
            var anchor = hit.Trackable.CreateAnchor(hit.Pose);

            // Andy should look at the camera but still be flush with the plane.
            andyObject.transform.LookAt(FirstPersonCamera.transform);
            andyObject.transform.rotation = Quaternion.Euler(0.0f,
                andyObject.transform.rotation.eulerAngles.y, andyObject.transform.rotation.z);

            // Make Andy model a child of the anchor.
            andyObject.transform.parent = anchor.transform;
        }
        if (landmarkEven != null && landmarkOdd != null)
        {
            Debug.DrawLine(landmarkEven.transform.position, landmarkOdd.transform.position, Color.green);
        }

这样做的主要目的是根据该线的方向实例化第三个对象。如果有人看到我的代码有些奇怪,或者有任何想法以其他方式实现它。

如果问题出在 phone,那是因为 Debug.DrawLine 仅用于在 Unity Editor 播放模式下进行调试。