microsoft / MixedReality-WorldLockingTools-Unity

Unity tools to provide a stable coordinate system anchored to the physical world.
https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/README.html
MIT License
188 stars 45 forks source link

GetFrozenAnchorIds returns empty array #307

Open TheXRMonk opened 1 year ago

TheXRMonk commented 1 year ago

Been trying to implement a MagicLeap2 AnchorManager and SpongyAnchor to use with WLT. Have pretty good results so far, but the loading part is weird. I\m jus trying to copy the logic from other anchor providers and they use the plugin.GetFrozenAnchorIds() which they iterate over to figure out which anchors to load, but this array is always empty for me, even though I have automatic saving and loading on (and my spongy Magic Leap 2 anchors are being saved and restored correctly).

fieldsJacksonG commented 1 year ago

The anchors retrieved from GetFrozenAnchorIds come from the frozen world runtime, whose state is saved/ loaded in the frozenWorldState.hkfw file: Saved here: https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/blob/204e507df8e7a1b6e53a4f95cfa3710655ec5945/Assets/WorldLocking.Core/Scripts/WorldLockingManager.cs#L936

Loaded here: https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/blob/204e507df8e7a1b6e53a4f95cfa3710655ec5945/Assets/WorldLocking.Core/Scripts/WorldLockingManager.cs#L989

This file must be deserialized into the underlying frozen world DLL to populate the frozen world runtime with the saved state.

The serializer and deserializer are implemented in Plugin.cs: https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/blob/master/Assets/WorldLocking.Engine/Plugin.cs

See here: Saving: https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/DocGen/Documentation/Concepts/Advanced/Architecture/FrozenWorldDLL.html#serializing-saving-frozen-world-state

Loading: https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/DocGen/Documentation/Concepts/Advanced/Architecture/FrozenWorldDLL.html#deserializing-loading-and-restoring-frozen-world-state