Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Persisting both anchors and holograms

Hi,

I've been using world anchor store to save information about anchors and recreating them in the next session. What I couldn't figure out is how to determine what holograms were placed on those anchors. Is there any suggested way of persisting holograms for hololens?

Marcin

Best Answer

Answers

  • Options

    Hi, @MarcinK

    There are two things to this:

    1. How do you know what hologram was placed and whose anchor was saved to the store? Well, when you save a hologram you assign a world anchor id to it. So then later on you can enumerate all the ids form the store and restore you holograms. You simply need to establish a one-to-one correspondence between holograms and ids.
    2. To persist the state of the app apart from spatial mapping you can simply use Unity's PlayerPrefs or really any other method of persistence of custom data.

    Or did I misunderstand the question? It seem a little bit unclear to me as since you figured how to save and re-load the anchors with their corresponding ids you shouldn't even be asking this question, you already did the job.

    Building the future of holographic navigation. We're hiring.

  • Options

    @stepan_stulov
    Thanks for the reply!

    As far as i understand World Anchor Store allows storing only World Anchors without any reference to GameObjects they were attached to. I was wandering if HoloToolKit provides any way of saving GameObjects with their corresponding anchors.

    From your post i understand that GameObjects have to be saved separately and then assigned to their Anchors from World Anchor Store when application restarts. Is that right?

  • Options

    Correct, world anchor store, just as its name suggests, only stores a table of world anchors (however they're encoded) by their unique string IDs. It doesn't care what exactly you do with it: create game objects with, use for some wild topology calibration or nothing at all.

    You can't really "save GameObjects" per se, unless you use some kind of high-level scene serialization plugin. What you usually do is save only that which suffices for restoring. For example game object names, what prefab they're instantiated from and their transforms. Then you can read it back and re-create new game objects from that data. But this is your application-level code. It won't be in any framework. It's on you and it highly depends on your requirements.

    Technically, with the world anchor store for anchors and PlayerPrefs for whatever else state you have two sources of data that make up the actual runtime state of your holograms. You can always give one of those sources an "authority". I recommend giving it to PlayerPrefs. So you read a list of you saved holograms and what prefabs they're instances of and instantiate accordingly. Then you supplement those holograms with anchors from the store. If the store doesn't have an anchor there - bad luck, next time. If there are are some excessive anchors, for which no objects exists anymore, - just clean them up.

    HoloToolkit doesn't provide any game object persistence as far as I know because it doesn't need to, it already exists in the lower level API: PlayerPrefs.

    Building the future of holographic navigation. We're hiring.

Sign In or Register to comment.