首页 > 解决方案 > ARCore + Unity:在 SessionConfig 上设置 PlaneFindingMode 对平面检测没有影响

问题描述

在我的 AR 应用程序中,我希望一些内容只能放置在墙壁上,而一些内容只能放置在地板上。我试图通过在分配给会话的 ARCoreSessionConfig 对象上设置 PlaneFindingMode 来实现这一点,然后重置会话,但无论我选择什么选项,应用程序仍然会检测水平和垂直表面。

public void SetVertical(bool vertical)
{
    if (vertical)
    {
        config.PlaneFindingMode = DetectedPlaneFindingMode.Vertical;
    }
    else
    {
        config.PlaneFindingMode = DetectedPlaneFindingMode.Horizontal;
    }

    StartCoroutine(ResetSession());
}

private IEnumerator ResetSession()
{
    ARCoreSession session = goARCoreDevice.GetComponent<ARCoreSession>();
    ARCoreSessionConfig myConfig = session.SessionConfig;

    DestroyImmediate(session);

    yield return null;

    session = goARCoreDevice.AddComponent<ARCoreSession>();
    session.SessionConfig = myConfig;
    session.enabled = true;
}

我还发现,即使我删除此代码并手动设置 PlaneFindingMode,也会出现相同的结果。即使我将 PlaneFindingMode 设置为禁用,它仍然会在墙壁和地板上找到飞机。

配置肯定分配给会话,所以我不知道在哪里看。我在这里错过了其他东西吗?

标签: unity3darcore

解决方案


推荐阅读