Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
Persistence changes in MROpenXR (#292)
Browse files Browse the repository at this point in the history
* Add version define for MROpenXR 1.4.

* New MROpenXR APIs, and version up to 1.5.10_dev.

* Fix formatting glitch.
  • Loading branch information
fast-slow-still authored May 17, 2022
1 parent 0522900 commit 204e507
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"name": "com.unity.xr.openxr",
"expression": "",
"define": "WLT_XR_OPENXR_PRESENT"
},
{
"name": "com.microsoft.mixedreality.openxr",
"expression": "1.4",
"define": "WLT_MICROSOFT_OPENXR_1_4_OR_NEWER"
}
],
"noEngineReferences": false
Expand Down
12 changes: 11 additions & 1 deletion Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF_OpenXR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#define WLT_XR_PERSISTENCE
#endif // WLT_XR_PERSISTENCE

#if WLT_MICROSOFT_OPENXR_1_4_OR_NEWER
#define WLT_USE_ARMANAGER_EXTENSIONS
#endif // WLT_MICROSOFT_OPENXR_1_4_OR_NEWER

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -30,6 +34,9 @@
#if WLT_XR_PERSISTENCE
using Microsoft.MixedReality.OpenXR;
using UnityEngine.XR.ARSubsystems;
#if WLT_USE_ARMANAGER_EXTENSIONS
using Microsoft.MixedReality.OpenXR.ARFoundation;
#endif // WLT_USE_ARMANAGER_EXTENSIONS
#endif // WLT_XR_PERSISTENCE


Expand Down Expand Up @@ -67,8 +74,11 @@ private async Task<XRAnchorStore> EnsureOpenXRAnchorStore()
if (openXRAnchorStore == null)
{
DebugLogExtra($"Getting new OpenXR XRAnchorStore.");
// openXRAnchorStore = await arAnchorManager.LoadAnchorStoreAsync();
#if WLT_USE_ARMANAGER_EXTENSIONS
openXRAnchorStore = await arAnchorManager.LoadAnchorStoreAsync();
#else // WLT_USE_ARMANAGER_EXTENSIONS
openXRAnchorStore = await XRAnchorStore.LoadAsync(arAnchorManager.subsystem);
#endif // WLT_USE_ARMANAGER_EXTENSIONS
}
openXRPersistence = openXRAnchorStore != null;
return openXRAnchorStore;
Expand Down
4 changes: 3 additions & 1 deletion Assets/WorldLocking.Core/Scripts/WorldLockingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public class WorldLockingManager
/// The version of this release. This will be displayed in the WorldLockingContext component in the Unity Inspector,
/// allowing quick visual verification of the version of World Locking Tools for Unity currently installed.
/// It has no effect in code, but serves only as a label.
/// A "_dev" suffix means it's the main branch under current development (between releases). When released,
/// the _dev suffix is removed. For example, 1.5.9_dev is released as 1.5.9.
/// </summary>
public static string Version => "1.5.9";
public static string Version => "1.5.10_dev";

/// <summary>
/// The configuration settings may only be set as a block.
Expand Down
13 changes: 11 additions & 2 deletions Assets/WorldLocking.Core/Scripts/XR/AnchorManagerXR_OpenXR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#define WLT_XR_PERSISTENCE
#endif // WLT_XR_PERSISTENCE

#if WLT_MICROSOFT_OPENXR_1_4_OR_NEWER
#define WLT_USE_ARSUBSYSTEM_EXTENSIONS
#endif // WLT_MICROSOFT_OPENXR_1_4_OR_NEWER

//#define WLT_EXTRA_LOGGING

#if WLT_DISABLE_LOGGING
Expand All @@ -22,8 +26,10 @@
using UnityEngine.XR;

#if WLT_XR_PERSISTENCE
//using Microsoft.MixedReality.ARSubsystems;
using Microsoft.MixedReality.OpenXR;
#if WLT_USE_ARSUBSYSTEM_EXTENSIONS
using Microsoft.MixedReality.OpenXR.ARSubsystems;
#endif // WLT_USE_ARSUBSYSTEM_EXTENSIONS
#endif // WLT_XR_PERSISTENCE

using UnityEngine.SpatialTracking;
Expand All @@ -47,8 +53,11 @@ private async Task<XRAnchorStore> EnsureOpenXRAnchorStore()
if (openXRAnchorStore == null)
{
DebugLogExtra($"Getting new OpenXR XRAnchorStore.");
// openXRAnchorStore = await xrAnchorManager.LoadAnchorStoreAsync();
#if WLT_USE_ARSUBSYSTEM_EXTENSIONS
openXRAnchorStore = await xrAnchorManager.LoadAnchorStoreAsync();
#else // WLT_USE_ARSUBSYSTEM_EXTENSIONS
openXRAnchorStore = await XRAnchorStore.LoadAsync(xrAnchorManager);
#endif // WLT_USE_ARSUBSYSTEM_EXTENSIONS
}
openXRPersistence = openXRAnchorStore != null;
return openXRAnchorStore;
Expand Down

0 comments on commit 204e507

Please sign in to comment.