使用MRTK中的WorldAnchorManager [英] Using WorldAnchorManager from MRTK

查看:825
本文介绍了使用MRTK中的WorldAnchorManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我尝试使用实验性WorldAnchorManager(请参阅官方API条目).总的来说,一切看起来都很轻松.首先,您必须创建Manager的实例,并将其分配给要使用它的脚本.之后,应该可以使用以下代码将锚点加载到对象中:

at the moment I try to use the experimental WorldAnchorManager (see official API entry) of MRTK 2.4. Over all everything looks quiet easy. First of all, you have to create an Instance of the Manager and assign it to the script where you want to use it. Afterwards, it should be possible to load an anchor into a object with this piece of code:

public string AttachAnchor(GameObject gameObjectToAnchor, string anchorName = null)

此代码还保存了API中提到的Anchor.

This code also saves the Anchor as mentioned in the API.

如果我想从GameObject中删除锚点,可以致电:

If I want to remove the anchor from a GameObject I can call:

public void RemoveAnchor(GameObject gameObjectToUnanchor)

在我的Unity项目(2019.3.7)中,我计算了一些游戏对象的位置,然后通过上述方法为它们分配了锚点.如果我移动了游戏对象,我将移除锚点,并在移动过程完成后再次锚定它们.

In my Unity-Project (2019.3.7) I calculate a position of some gameobjects and afterwards assign them Anchors via the Method above. If I move the Gameobjects, I remove the anchors and attatch them again after the moving process is finished.

如果我将解决方案部署在HoloLens2上,放置游戏对象,固定锚点,并获得一条记录,说明已经成功固定了锚点,则应该在整个会话期间在hololens2上本地访问这些锚点.不幸的是,在我的情况下,在设备上重新启动应用程序并重新加载锚之后,无法加载它们. Manager日志无法为' GO名称'...创建新的锚点加载锚点".

If I deploy the solution on HoloLens2, position the gameobjects, attatch the anchors and get a log that the anchors have been attatched successfully, those anchors should be accessable on hololens2 locally across sessions. Unfortunately, in my case after restarting the application on the device and reloading the anchors, they cant be loaded. The Manager Logs "Anchor could not be loaded for 'GO name' ... creating a new anchor".

我不确定我做错了什么,该经理应该已经工作了吗?我是否需要在Unity项目中配置某些内容才能使用Manager?也许有人已经在使用Manager,可以帮助我解决此问题.

I am not sure what I did wrong, should this Manager already work? Do I have to Configure something in the Unity-Project to use the Manager? Maybe someone already uses the Manager and can help me with this issue.

推荐答案

好,我编写了一个小示例应用程序,该应用程序使用了MRTK的世界锚点管理器. 基于以下步骤: https://docs.microsoft.com/zh-CN/windows/mixed-reality/develop/unity/persistence-in-unity ,该应用程序使用户可以将多维数据集放置在任何位置,从而自动创建和保存锚点每次释放多维数据集. 当应用关闭并重新启动时,将加载锚并将多维数据集放置在其保存的位置.

Ok, I wrote a small example app that uses the world anchor manager from MRTK. Based on these steps: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/persistence-in-unity, the app enables the user to place a cube at any location, automatically creating and saving an anchor each time the cube is released. When the app is closed and re-started, the anchor is loaded and the cube is placed at its saved location.

可在此处找到源: https://github.com/anders- lundgren/mrtk-world-anchors

在Unity 2019.4.9f1,Visual Studio 2019,HoloLens 2(内部版本10.0.19041.1377)上进行验证.

Verified on Unity 2019.4.9f1, Visual Studio 2019, HoloLens 2 (Build 10.0.19041.1377).

根据上述MRTK入门教程,除了上述步骤之外,我还添加了基本的MRTK组件,网址为 https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/README_ManipulationHandler.html .

In addition to the above steps, I added the base MRTK components, according to the MRTK getting started tutorial at https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/tutorials/mr-learning-base-02. I also added a simple debugging prefab from this example: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/tutorials/mr-learning-asa-02#importing-the-tutorial-assets, and the manipulation handler from this example: https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/README_ManipulationHandler.html.

这篇关于使用MRTK中的WorldAnchorManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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