Search code examples
unity-game-enginespatialhololens

Using WorldAnchorManager from MRTK


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)

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

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

public void RemoveAnchor(GameObject gameObjectToUnanchor)

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.

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".

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.


Solution

  • Even if it is far too late, I want to finish this question. The WorldAnchorManager only functions when built for the WSA platform using legacy XR. It doesn´t work within the editor or with the Unity-XR-Plugin. I tried to use it with the XR-Plugin.