As noted here, the documentation on this topic seems very limited. I know that I need a "World Anchor". I am having problems finding any documentation on how to use such an anchor. This is the closest documentation I can find from Microsoft, but leaves out a lot of details and doesn't have any working examples. The documentation from Unity isn't much better, although it addresses WorldAnchor
specifically.
I started by simply adding a component to the GameObject via the Unity editor, via "Add Component" > "AR" > "World Anchor". That did not seem to do anything.
Then I found this demo code from this YouTube video, and started implementing that (it is way more complicated than what I need).
I finally learned that there is a WorldAnchorManager
from this discussion, and attempted to use it via the code below. This also has had no effect:
using Microsoft.MixedReality.Toolkit.Experimental.Utilities;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.WSA;
using UnityEngine.XR.WSA.Persistence;
public class HololensWorldAnchorManager : MonoBehaviour
{
private WorldAnchorManager Manager;
// Start is called before the first frame update
void Start()
{
// Load and get a reference to the store.
this.AttachAnchor();
}
private void AttachAnchor()
{
this.Manager = new WorldAnchorManager();
this.Manager.AttachAnchor(this.gameObject);
}
// more class stuff...
}
After following the directions here (which are out of date and DO NOT work anymore), I finally figured out how to make my project not in a window on the Hololens... but now without the anchors working, I see my hologram as if it is glued to the front of my face (and I also see the framerate bar even in the release version - I don't want that either).
Am I missing something? How do you actually use a world anchor? I just want my single hologram to stay put, in a physical space, and never move. Ideally, this location is set once before runtime and never changes. As a backup, the user placing the hologram once and then it staying there is acceptable. I don't even need persistence nor multiple users to see it nor multiple anchors...
UPDATE: I added a second object to the scene, and verified that moving with the Hololens on does not actually navigate around the scene at all. The anchors may be working fine, but I cannot verify this since the entire scene is moving with the user.
I also then tried outputting a Unity scene to the Hololens that is identical to the problem one, except the MRTK is not set up on it. This leads to the exact same result as the Hololens scene. Maybe I am missing a setup or build configuration step or something? The MRTK camera rig works fine in the Unity player... it is only on the Hololens that issues arise.