在 Unity 中暂停 Google ARCore [英] Pause Google ARCore in Unity

查看:26
本文介绍了在 Unity 中暂停 Google ARCore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以暂停,或者至少阻止 ARCore 旋转屏幕.我有一个菜单,我用来通过销毁游戏对象并实例化它来在 AR 场景之间切换",但是当我重新激活菜单时,SessionComponent 继续控制相机,因为它仍在跟踪剩余的锚点.我不知道如何删除锚点,因为它是通过调用 Session.CreateAnchor 创建的,而 Session 似乎没有删除锚点的方法.我假设删除锚点可能是阻止 ARCore 跟踪的最佳方法,并且类似于重置它,但我不知道如何删除锚点.我尝试实际删除 Anchor,但它似乎仍保留在列表中,或者似乎仍有某些内容试图在 Session 和 Anchor 类中跟踪它,从而导致 nullptr 异常.

Is there any way to pause, or at least stop ARCore from rotating the screen. I have a menu that I use to "switch" between AR scenes by destroying the gameobject and instantiating it, but when I reactivate the menu the SessionComponent continues to control the camera because it is still tracking the leftover anchor. I have no idea how to delete the anchor because of the fact that it is created by calling Session.CreateAnchor and Session doesn't seem to have a method for removing anchors. I'm assuming that removing the anchor could be the best way to stop ARCore from tracking and would be similar to resetting it, but I can't find out how to remove the Anchor. I tried actually deleting the Anchor, but it seems to be still kept in a list or there seems to be something that still attempt to track it in the Session and Anchor class that causes a nullptr exception.

推荐答案

使用 ARCoreSession.Destroy(yourAnchor),如果这不起作用,请使用 ARCoreSession.DestroyImmediate(yourAnchor).

Use ARCoreSession.Destroy(yourAnchor), if this doesn't work use ARCoreSession.DestroyImmediate(yourAnchor).

官方文档中还没有更新.但是,这就是你实现它的方式

It is still not updated in the official documentation. But, this is how you achieve it

干杯!

这篇关于在 Unity 中暂停 Google ARCore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆