首页 > 解决方案 > 在 Unity 中重新启动/暂停/恢复 ARCore 会话

问题描述

如何在 ARCore 中暂停/恢复会话?我有一组画布,我经常在它们之间切换。这些画布中只有少数使用了 ARCore。

如何在这些画布中实现 ARCore 服务?

我还想在切换到其他画布时清除 ARCore 数据。

标签: c#unity3daugmented-realityarcore

解决方案


目前 Unity 中没有其他方法可以暂停/恢复 ARCore 会话

要在 Unity 中重新启动 ARCore 会话,您可以使用以下两种方法之一:Destroy(session)DestroyImmediate(session). 其中一种方法绝对适合您。

ARCoreSession session = goARCoreDevice.GetComponent<ARCoreSession>();
ARCoreSessionConfig myConfig = session.SessionConfig;

DestroyImmediate(session);
// Destroy(session);
yield return null;

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

这是Object.DestroyImmediate()Object.Destroy()函数的 Unity 文档。


推荐阅读