Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用ArCore显示Debug.drawLine()_C#_Unity3d_Arcore - Fatal编程技术网

C# 使用ArCore显示Debug.drawLine()

C# 使用ArCore显示Debug.drawLine(),c#,unity3d,arcore,C#,Unity3d,Arcore,我试图在我用ARCore实例化的两个对象之间显示一条线。我在虚拟环境(没有ARCORE)中没有任何问题,但当我想将其用于增强现实时,我的标记会显示出来,但不会显示我的线条。我也在努力调试它,因为我没有任何手机日志 我的代码: // Raycast against the location the player touched to search for planes. TrackableHit hit; TrackableHitFlags raycastFil

我试图在我用ARCore实例化的两个对象之间显示一条线。我在虚拟环境(没有ARCORE)中没有任何问题,但当我想将其用于增强现实时,我的标记会显示出来,但不会显示我的线条。我也在努力调试它,因为我没有任何手机日志

我的代码:

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

其主要目的是基于该线的方向实例化第三个对象。如果有人看到我的代码有什么奇怪的地方,或者有任何想法用另一种方式来实现它。

如果问题在电话上,那是因为只在Unity Editor播放模式下进行调试。

如果问题在电话上,那是因为只在Unity Editor播放模式下进行调试