Exemple #1
0
        public static async Task <bool> ExportAnchors(this WindowsMRAnchorSubsystem wmrrp, Stream output)
        {
            bool ret = false;

#if ENABLE_WINMD_SUPPORT
            try
            {
                Debug.Log($"Getting Spatial Anchor Transfer Manager Access");
                var access = await SpatialAnchorTransferManager.RequestAccessAsync();

                if (access != SpatialPerceptionAccessStatus.Allowed)
                {
                    Debug.Log($"Access check failed with {access}");
                    return(ret);
                }

                Debug.Log($"Getting Spatial Anchor Store");
                var spatialAnchorStore = await SpatialAnchorManager.RequestStoreAsync();

                if (spatialAnchorStore == null)
                {
                    return(ret);
                }

                Debug.Log($"Setting up stream");
                var stream = output.AsOutputStream();

                Debug.Log($"Getting saved anchors");
                var anchors = spatialAnchorStore.GetAllSavedAnchors();
                if (anchors == null || anchors.Count == 0)
                {
                    Debug.Log("No anchors to exort!!!");
                }
                else
                {
                    Debug.Log("Exporting anchors...");
                    ret = await SpatialAnchorTransferManager.TryExportAnchorsAsync(anchors, stream);

                    Debug.Log(ret ? "SUCCESS" : "FAILURE");
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                ret = false;
            }
#else
            Debug.LogError("This API is only available for use in UWP based applications.");
#endif //ENABLE_WINMD_SUPPORT
            return(ret);
        }
Exemple #2
0
#pragma warning disable CS0618
#pragma warning disable CS1998
        public static async Task <bool> ImportAnchors(this WindowsMRAnchorSubsystem wmrrp, Stream input)
        {
            bool ret = false;

#if ENABLE_WINMD_SUPPORT
            try
            {
                var access = await SpatialAnchorTransferManager.RequestAccessAsync();

                if (access != SpatialPerceptionAccessStatus.Allowed)
                {
                    return(ret);
                }

                var spatialAnchorStore = await SpatialAnchorManager.RequestStoreAsync();

                if (spatialAnchorStore == null)
                {
                    return(ret);
                }

                var anchors = await SpatialAnchorTransferManager.TryImportAnchorsAsync(input.AsInputStream());

                foreach (var kvp in anchors)
                {
                    spatialAnchorStore.TrySave(kvp.Key, kvp.Value);
                }

                ret = true;
            }
            catch (Exception e)
            {
                Debug.Log(e);
                ret = false;
            }
#else
            Debug.LogError("This API is only available for use in UWP based applications.");
#endif //ENABLE_WINMD_SUPPORT
            return(ret);
        }
Exemple #3
0
 public static void ReloadStorage(this WindowsMRAnchorSubsystem wmrrp)
 {
     NativeApi.UnityWindowsMR_refPoints_ReloadStorage();
 }
Exemple #4
0
 public static void ClearAllAnchorsFromStorage(this WindowsMRAnchorSubsystem wmrrp)
 {
     NativeApi.UnityWindowsMR_refPoints_ClearAllFromStorage();
 }