ARCore 会识别地板并在创建对象后尝试停止平面识别

ARCore will recognize the floor and try to stop the plane recognition after creating the object

在ARCore教程中,如果你用相机识别出一个平面并触摸它,你会创建一个物体,如果你识别出另一个平面,你可以在那里创建另一个物体。 但是,我想识别一个平面,然后创建一个对象,然后停止平面识别,同时隐藏已经识别的范围。

算法如下: 识别地板->触摸识别范围创建物体->停止平面识别,隐藏第一个识别范围,只留下物体

我只成功创建了一个对象并阻止了其他对象的创建。 但我不知道我应该如何触摸代码......请帮助我。

要停止平面识别,您必须访问 ARCore 会话配置

// If you are using ARCore 1.2
FindObjectOfType<ARCoreSession>().SessionConfig.PlaneFindingMode = DetectedPlaneFindingMode.Disabled;

// If you are using a previous ARCore version
FindObjectOfType<ARCoreSession>().SessionConfig.EnablePlaneFinding = false;

要隐藏已经跟踪的平面,您需要找到它们并禁用它们的网格渲染器。在 ARCore 中,你可以这样做(我没有测试过)

DetectedPlaneVisualizer[] detectedPlanes = FindObjectsOfType<DetectedPlaneVisualizer>();
for(int i = 0; i < detectedPlanes.Length; i++)
{
    detectedPlanes[i].transform.GetComponent<MeshRenderer>().enabled = false;
}

但是,您可以使用我写的 ARCore plugin 来简化开发。这样,您只需使用一行代码即可禁用跟踪平面

EazyARCoreInterface.VisualizeDetectedPlanes = false;