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

Commit 6bded10

Browse files
Update to ASA v2.11 (#241)
* Update to ASA v2.11.0. Also prepares for upgrade to ASA v2.12.0 (removing workarounds). Also adds iOS ASA reference. * Update package generation for creating WLT v1.5.6.
1 parent 4cd7c30 commit 6bded10

12 files changed

Lines changed: 76 additions & 34 deletions

File tree

Assets/WorldLocking.ASA/Microsoft.MixedReality.WorldLocking.ASA.asmdef

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"Microsoft.MixedReality.WorldLocking.Core",
77
"Microsoft.MixedReality.WorldLocking.Tools",
88
"AzureSpatialAnchors.SDK.Windows.Runtime",
9-
"AzureSpatialAnchors.SDK.Android.Runtime"
9+
"AzureSpatialAnchors.SDK.Android.Runtime",
10+
"AzureSpatialAnchors.SDK.iOS.Runtime",
11+
"Unity.XR.ARFoundation"
1012
],
1113
"includePlatforms": [
1214
"Android",
@@ -25,6 +27,21 @@
2527
"name": "com.microsoft.azure.spatial-anchors-sdk.core",
2628
"expression": "",
2729
"define": "WLT_ASA_INCLUDED"
30+
},
31+
{
32+
"name": "com.microsoft.azure.spatial-anchors-sdk.core",
33+
"expression": "2.11",
34+
"define": "WLT_ASA_V2_11_0_OR_NEWER"
35+
},
36+
{
37+
"name": "com.microsoft.azure.spatial-anchors-sdk.core",
38+
"expression": "2.12",
39+
"define": "WLT_ASA_V2_12_0_OR_NEWER"
40+
},
41+
{
42+
"name": "com.unity.xr.arfoundation",
43+
"expression": "",
44+
"define": "WLT_ARFOUNDATION_PRESENT"
2845
}
2946
],
3047
"noEngineReferences": false

Assets/WorldLocking.ASA/Scripts/PublisherASA.cs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
//#define WLT_EXTRA_LOGGING
55
#define WLT_LOG_ASA_SETUP
66

7+
#if !WLT_ASA_V2_11_0_OR_NEWER
8+
#define WLT_ASA_V2_10_2_OR_OLDER
9+
#endif // WLT_ASA_V2_11_0_OR_NEWER
10+
11+
#if UNITY_WSA && !WLT_ASA_V2_12_0_OR_NEWER
12+
#define WLT_ASA_SESSION_ORIGIN_WORKAROUND
13+
#endif // UNITY_WSA
14+
715
#if WLT_DISABLE_LOGGING
816
#undef WLT_EXTRA_LOGGING
917
#undef WLT_LOG_ASA_SETUP
@@ -18,7 +26,16 @@
1826
#if WLT_ASA_INCLUDED
1927
using Microsoft.Azure.SpatialAnchors;
2028
using Microsoft.Azure.SpatialAnchors.Unity;
29+
#if WLT_ASA_V2_10_2_OR_OLDER
2130
using NativeAnchor = Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent;
31+
#endif // WLT_ASA_V2_10_2_OR_OLDER
32+
#if WLT_ASA_V2_11_0_OR_NEWER
33+
#if WLT_ARFOUNDATION_PRESENT
34+
using NativeAnchor = UnityEngine.XR.ARFoundation.ARAnchor;
35+
#else // WLT_ARFOUNDATION_PRESENT
36+
#error AR Foundation required for ASA v2.11.0 or newer. Please install AR Foundation package.
37+
#endif // WLT_ARFOUNDATION_PRESENT
38+
#endif // WLT_ASA_V2_11_0_OR_NEWER
2239
#endif // WLT_ASA_INCLUDED
2340

2441
using Microsoft.MixedReality.WorldLocking.Core;
@@ -41,7 +58,7 @@ namespace Microsoft.MixedReality.WorldLocking.ASA
4158
/// </remarks>
4259
public class PublisherASA : MonoBehaviour, IPublisher
4360
{
44-
#region Inspector fields
61+
#region Inspector fields
4562

4663
[Tooltip("Enable coarse relocation")]
4764
[SerializeField]
@@ -388,7 +405,7 @@ public async void Setup()
388405
#endif // WLT_ASA_INCLUDED
389406
}
390407

391-
#region Implementation of IPublisher
408+
#region Implementation of IPublisher
392409
/// <inheritdocs />
393410
public ReadinessStatus Status
394411
{
@@ -688,13 +705,13 @@ public async Task PurgeArea(float radius)
688705
throw new NotSupportedException("Trying to use PublisherASA without Azure Spatial Anchors installed.");
689706
#endif // WLT_ASA_INCLUDED
690707
}
691-
#endregion // Implementation of IPublisher
708+
#endregion // Implementation of IPublisher
692709

693-
#endregion // Public API
710+
#endregion // Public API
694711

695712
#if WLT_ASA_INCLUDED
696713

697-
#region Internal implementations
714+
#region Internal implementations
698715

699716
private static void LogASASetup(string message)
700717
{
@@ -1057,9 +1074,9 @@ record = await DownloadRecord(cloudAnchorId);
10571074
}
10581075

10591076

1060-
#endregion // Internal implementations
1077+
#endregion // Internal implementations
10611078

1062-
#region Internal helpers
1079+
#region Internal helpers
10631080

10641081
/// <summary>
10651082
/// Convert the collection of ids to an array.
@@ -1214,10 +1231,10 @@ private async Task<LocalPeg> InternalCreateLocalPeg(string id, Pose lockedPose)
12141231
+ $" pa={WorldLockingManager.GetInstance().AnchorManager.AnchorFromSpongy.Inverse().Multiply(frozenPose).position.ToString("F3")}"
12151232
);
12161233

1217-
#if UNITY_WSA
1234+
#if WLT_ASA_SESSION_ORIGIN_WORKAROUND
12181235
// mafinc - workaround for bug in ASA NativeAnchor.
12191236
peg.anchorHanger.transform.SetLocalPose(Pose.identity);
1220-
#endif // UNITY_WSA
1237+
#endif // WLT_ASA_SESSION_ORIGIN_WORKAROUND
12211238

12221239
#if WLT_EXTRA_LOGGING
12231240
// mafinc - trash
@@ -1227,7 +1244,7 @@ private async Task<LocalPeg> InternalCreateLocalPeg(string id, Pose lockedPose)
12271244
return peg;
12281245
}
12291246

1230-
#region TRASH
1247+
#region TRASH
12311248

12321249
#if WLT_EXTRA_LOGGING
12331250
private static void PrintScene()
@@ -1271,7 +1288,7 @@ private static void PrintSubtree(int consolePriority, Transform subroot, int ind
12711288
}
12721289
#endif // WLT_EXTRA_LOGGING
12731290

1274-
#endregion // TRASH
1291+
#endregion // TRASH
12751292

12761293
/// <summary>
12771294
/// If cloud anchor id is unknown, add the record, else update the record.
@@ -1342,15 +1359,15 @@ private async Task<AnchorRecord> RecordFromCloud(AnchorRecord record)
13421359
Debug.Assert(record.cloudAnchor != null, $"Trying to create native resources from a null cloud anchor");
13431360
var wltMgr = WorldLockingManager.GetInstance();
13441361
await Task.Yield();
1345-
#if UNITY_WSA
1362+
#if WLT_ASA_SESSION_ORIGIN_WORKAROUND
13461363
Pose spongyPose = record.cloudAnchor.GetPose();
13471364
var lockedPose = wltMgr.LockedFromSpongy.Multiply(spongyPose);
13481365
SimpleConsole.AddLine(ConsoleMid, $"RFC: sp={spongyPose.position.ToString("F3")} lp={lockedPose.position.ToString("F3")}");
13491366
#else // Android/iOS
13501367
Pose frozenPose = record.cloudAnchor.GetPose();
13511368
var lockedPose = wltMgr.LockedFromFrozen.Multiply(frozenPose);
13521369
SimpleConsole.AddLine(ConsoleMid, $"RFC: fp={frozenPose.position.ToString("F3")} lp={lockedPose.position.ToString("F3")}");
1353-
#endif // UNITY_WSA
1370+
#endif // WLT_ASA_SESSION_ORIGIN_WORKAROUND
13541371
record.localPeg = await InternalCreateLocalPeg(record.cloudAnchorId, lockedPose);
13551372
AnchorRecord.DebugLog(record, "RecordFromCloud:");
13561373
SimpleConsole.AddLine(ConsoleMid, $"Got record={record.cloudAnchorId} with {record.cloudAnchor.AppProperties.Count} properties.");
@@ -1361,9 +1378,9 @@ private async Task<AnchorRecord> RecordFromCloud(AnchorRecord record)
13611378
return record;
13621379
}
13631380

1364-
#endregion // Internal helpers
1381+
#endregion // Internal helpers
13651382

1366-
#region ASA events
1383+
#region ASA events
13671384

13681385
/// <summary>
13691386
/// Put incoming cloud anchors (from ASA thread) into a list for processing on main thread.
@@ -1426,9 +1443,9 @@ private void OnASAError(object sender, SessionErrorEventArgs args)
14261443
);
14271444
}
14281445

1429-
#endregion // ASA events
1446+
#endregion // ASA events
14301447

1431-
#region Setup helpers
1448+
#region Setup helpers
14321449

14331450
/// <summary>
14341451
/// Create a location provider if coarse relocation is enabled.
@@ -1528,9 +1545,9 @@ private void ReleaseBusy()
15281545
Debug.Assert(busy != null);
15291546
busy = null;
15301547
}
1531-
#endregion // Setup helpers
1548+
#endregion // Setup helpers
15321549

1533-
#region Awful stuff
1550+
#region Awful stuff
15341551

15351552
#if UNITY_ANDROID
15361553
private static readonly string[] androidPermissions = new string[]
@@ -1622,7 +1639,7 @@ private void PermissionCallback_Denied(string permission)
16221639
waitingState = PermissionWaiting.Denied;
16231640
}
16241641
#endif
1625-
#endregion // Awful stuff
1642+
#endregion // Awful stuff
16261643

16271644
#endif // WLT_ASA_INCLUDED
16281645
}

Assets/WorldLocking.Core/Scripts/ARF/AnchorManagerARF.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
#if UNITY_2020_1_OR_NEWER
1111

12-
#if UNITY_2020_4_OR_NEWER
12+
#if UNITY_2020_3_OR_NEWER
1313
#define WLT_ADD_ANCHOR_COMPONENT
14-
#endif // UNITY_2020_4_OR_NEWER
14+
#endif // UNITY_2020_3_OR_NEWER
1515

1616
#if WLT_ARFOUNDATION_PRESENT
1717

Assets/WorldLocking.Core/Scripts/ARF/SpongyAnchorARF.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#if UNITY_2020_1_OR_NEWER
55

6-
#if UNITY_2020_4_OR_NEWER
6+
#if UNITY_2020_3_OR_NEWER
77
#define WLT_ADD_ANCHOR_COMPONENT
8-
#endif // UNITY_2020_4_OR_NEWER
8+
#endif // UNITY_2020_3_OR_NEWER
99

1010
using UnityEngine;
1111
#if WLT_ARFOUNDATION_PRESENT

UPM/asa_files/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases)
44

5+
## 1.5.6 - Update to ASA v2.11.0.
6+
57
## 1.5.4 - Fix timing issue with ASA anchors sometimes not created in time.
68

79
## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4.

UPM/asa_files/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.microsoft.mixedreality.wlt.asa",
33
"displayName": "WLT-ASA",
4-
"version": "1.5.4",
4+
"version": "1.5.6",
55
"unity": "2020.3",
66
"msftFeatureCategory": "World Locking Tools",
77
"description": "World Locking Tools for Unity (WLT) + Azure Spatial Anchors (ASA)\n\nThis optional add-on to WLT leverages ASA to persist coordinate spaces across sessions and share them across devices.\nCross platform support includes HoloLens, Android, and iOS.",
@@ -35,7 +35,7 @@
3535
},
3636
"dependencies": {
3737
"com.microsoft.azure.spatial-anchors-sdk.core": "2.9.0",
38-
"com.microsoft.mixedreality.worldlockingtools": "1.5.4"
38+
"com.microsoft.mixedreality.worldlockingtools": "1.5.6"
3939
},
4040
"files": [
4141
"WorldLocking.ASA",

UPM/asa_samples_files/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases)
44

5+
## 1.5.6 - Update to ASA v2.11.0.
6+
57
## 1.5.4 - Fix timing issue with ASA anchors sometimes not created in time.
68

79
## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4.

UPM/asa_samples_files/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.microsoft.mixedreality.wlt.asa.samples",
33
"displayName": "WLT-ASA Samples",
4-
"version": "1.5.4",
4+
"version": "1.5.6",
55
"unity": "2020.3",
66
"msftFeatureCategory" : "World Locking Tools",
77
"description": "Example scenes and scripts leveraging Azure Space Anchors (ASA) to persist World Locked coordinate spaces across sessions and share across devices.\n\nFurther samples available at\nhttps://microsoft.github.io/MixedReality-WorldLockingTools-Samples/README.html",
@@ -36,9 +36,9 @@
3636
"dependencies": {
3737
"com.microsoft.azure.spatial-anchors-sdk.core": "2.9.0",
3838
"com.microsoft.mixedreality.toolkit.foundation": "2.7.0",
39-
"com.microsoft.mixedreality.wlt.asa": "1.5.4",
40-
"com.microsoft.mixedreality.worldlockingtools": "1.5.4",
41-
"com.microsoft.mixedreality.worldlockingsamples": "1.5.4"
39+
"com.microsoft.mixedreality.wlt.asa": "1.5.6",
40+
"com.microsoft.mixedreality.worldlockingtools": "1.5.6",
41+
"com.microsoft.mixedreality.worldlockingsamples": "1.5.6"
4242
},
4343
"files": [
4444
"package.json.meta",

UPM/core_files/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[See release notes](https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/releases)
44

5+
## 1.5.6 - Update to ASA v2.11.0.
6+
57
## 1.5.4 - Backward compatibility for Unity 2018 .NET backend.
68

79
## 1.5.3 - Remove dependency on tuple, and add MR Feature Tool support back to Unity 2018.4.

UPM/core_files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.microsoft.mixedreality.worldlockingtools",
33
"displayName": "WLT Core",
4-
"version": "1.5.4",
4+
"version": "1.5.6",
55
"unity": "2018.4",
66
"msftFeatureCategory" : "World Locking Tools",
77
"description": "World Locking Tools for Unity (WLT)\n\nLock AR virtual space to physical space automatically and intuitively, without requiring application management of anchors.\nPreserve object relative layout, while remaining perceptually stationary in the physical world.",

0 commit comments

Comments
 (0)