From b4770015c45242f75919067ac2417c8aa4db60dc Mon Sep 17 00:00:00 2001 From: yl-msft Date: Mon, 12 Sep 2022 14:32:19 -0700 Subject: [PATCH 1/3] Add the README to explain the usage of OpenXR version of the sample. --- README.md | 14 +++++++++++++- Sample/Assets/Scripts/QRCode.cs | 2 +- Sample/Assets/Scripts/QRCodesManager.cs | 2 +- Sample/Assets/Scripts/QRCodesSetup.cs | 2 +- Sample/Assets/Scripts/QRCodesVisualizer.cs | 2 +- Sample/Assets/Scripts/SampleQRCodes.asmdef | 2 +- Sample/Assets/Scripts/Singleton.cs | 2 +- Sample/Assets/Scripts/SpatialGraphNode.cs | 8 ++------ Sample/Assets/Scripts/SpatialGraphNodeTracker.cs | 5 +++-- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f53c187..3a99c78 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,19 @@ You can find the [full article on QR code tracking](https://docs.microsoft.com/w `QRCodesVisualizer.cs` - Handles all QR code visualizing in the scene and instantiates all QR codes in the local list kept in `QRCodesManager`. -`SpatialGraphCoordinateSystem.cs` - This script is attached to the QR code object and transforms real-world QR code coordinates into the Unity coordinate system. The script also places the virtual QR code in the scene at the same location as the real-world QR code. +`SpatialGraphNodeTracker.cs` - This script is attached to the QR code object and transforms real-world QR code coordinates into the Unity coordinate system. The script also places the virtual QR code in the scene at the same location as the real-world QR code. + +`SpatialGraphNode.cs` - This script is abstracting the tracking of a spatial graph static node, which represents the tracking information of QR code in a GUID id. + +## OpenXR sample + +Note that the ["main" branch](https://github.com/microsoft/MixedReality-QRCode-Sample/tree/main) of this sample is working with Unity's "Windows XR Plugin" which works with the WinRT APIs in in Unity 2019 or 2020 LTS versions. + +After upgrading to Unity 2020 or Unity 2021, You can also [use "OpenXR plugin" for HoloLens 2 developement](https://docs.microsoft.com/windows/mixed-reality/develop/unity/mixed-reality-openxr-plugin). With OpenXR plugin, the app can use the built-in support for [SpatialGraphNode](https://docs.microsoft.com/dotnet/api/microsoft.mixedreality.openxr.spatialgraphnode), and the QR code tracking will work mostly the same way as above. + +To view the OpenXR version of the QRCode tracking on HoloLens 2, please checkout the "openxr" branch of this sample repro, https://github.com/microsoft/MixedReality-QRCode-Sample/tree/OpenXR. +You can also inspect how to make modifications to existing QRCode Unity project to support OpenXR from this pull request: https://github.com/microsoft/MixedReality-QRCode-Sample/pull/18 + ## API Reference diff --git a/Sample/Assets/Scripts/QRCode.cs b/Sample/Assets/Scripts/QRCode.cs index 4e71950..bcd5919 100644 --- a/Sample/Assets/Scripts/QRCode.cs +++ b/Sample/Assets/Scripts/QRCode.cs @@ -4,7 +4,7 @@ using Microsoft.MixedReality.Toolkit.Input; using UnityEngine; -namespace SampleQRCodes +namespace Microsoft.MixedReality.SampleQRCodes { [RequireComponent(typeof(SpatialGraphNodeTracker))] public class QRCode : MonoBehaviour, IMixedRealityPointerHandler diff --git a/Sample/Assets/Scripts/QRCodesManager.cs b/Sample/Assets/Scripts/QRCodesManager.cs index 692ae9a..591d25d 100644 --- a/Sample/Assets/Scripts/QRCodesManager.cs +++ b/Sample/Assets/Scripts/QRCodesManager.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using UnityEngine; -namespace SampleQRCodes +namespace Microsoft.MixedReality.SampleQRCodes { public static class QRCodeEventArgs { diff --git a/Sample/Assets/Scripts/QRCodesSetup.cs b/Sample/Assets/Scripts/QRCodesSetup.cs index cffe025..2c8c590 100644 --- a/Sample/Assets/Scripts/QRCodesSetup.cs +++ b/Sample/Assets/Scripts/QRCodesSetup.cs @@ -3,7 +3,7 @@ using UnityEngine; -namespace SampleQRCodes +namespace Microsoft.MixedReality.SampleQRCodes { public class QRCodesSetup : MonoBehaviour { diff --git a/Sample/Assets/Scripts/QRCodesVisualizer.cs b/Sample/Assets/Scripts/QRCodesVisualizer.cs index da0e8ac..e1f6e06 100644 --- a/Sample/Assets/Scripts/QRCodesVisualizer.cs +++ b/Sample/Assets/Scripts/QRCodesVisualizer.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using UnityEngine; -namespace SampleQRCodes +namespace Microsoft.MixedReality.SampleQRCodes { public class QRCodesVisualizer : MonoBehaviour { diff --git a/Sample/Assets/Scripts/SampleQRCodes.asmdef b/Sample/Assets/Scripts/SampleQRCodes.asmdef index 826aacc..5b20f30 100644 --- a/Sample/Assets/Scripts/SampleQRCodes.asmdef +++ b/Sample/Assets/Scripts/SampleQRCodes.asmdef @@ -1,5 +1,5 @@ { - "name": "SampleQRCodes", + "name": "Microsoft.MixedReality.SampleQRCodes", "rootNamespace": "", "references": [ "Microsoft.MixedReality.Toolkit", diff --git a/Sample/Assets/Scripts/Singleton.cs b/Sample/Assets/Scripts/Singleton.cs index 7cc10a1..2977648 100644 --- a/Sample/Assets/Scripts/Singleton.cs +++ b/Sample/Assets/Scripts/Singleton.cs @@ -3,7 +3,7 @@ using UnityEngine; -namespace SampleQRCodes +namespace Microsoft.MixedReality.SampleQRCodes { /// /// Inherit from this base class to create a singleton. diff --git a/Sample/Assets/Scripts/SpatialGraphNode.cs b/Sample/Assets/Scripts/SpatialGraphNode.cs index cb45d87..2522816 100644 --- a/Sample/Assets/Scripts/SpatialGraphNode.cs +++ b/Sample/Assets/Scripts/SpatialGraphNode.cs @@ -3,7 +3,7 @@ using UnityEngine; -namespace SampleQRCodes.WindowsXR +namespace Microsoft.MixedReality.SampleQRCodes.WindowsXR { internal class SpatialGraphNode { @@ -68,11 +68,7 @@ public bool TryLocate(out Pose pose) pose = new Pose(translation, rotation); return true; } - else - { - // Debug.Log("Id= " + id + " Unable to locate qrcode" ); - } -#endif // WINDOWS_UWP +#endif return false; } } diff --git a/Sample/Assets/Scripts/SpatialGraphNodeTracker.cs b/Sample/Assets/Scripts/SpatialGraphNodeTracker.cs index bfcff8a..befef7b 100644 --- a/Sample/Assets/Scripts/SpatialGraphNodeTracker.cs +++ b/Sample/Assets/Scripts/SpatialGraphNodeTracker.cs @@ -3,9 +3,10 @@ using UnityEngine; using Microsoft.MixedReality.Toolkit.Utilities; -using SpatialGraphNode = SampleQRCodes.WindowsXR.SpatialGraphNode; -namespace SampleQRCodes +using SpatialGraphNode = Microsoft.MixedReality.SampleQRCodes.WindowsXR.SpatialGraphNode; + +namespace Microsoft.MixedReality.SampleQRCodes { internal class SpatialGraphNodeTracker : MonoBehaviour { From 0ab0fe51ee0f6c776b55a79af469a36b55989274 Mon Sep 17 00:00:00 2001 From: yl-msft Date: Mon, 12 Sep 2022 15:24:37 -0700 Subject: [PATCH 2/3] Reformat the packages/manifest.json --- Sample/Packages/manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sample/Packages/manifest.json b/Sample/Packages/manifest.json index c8f4ca8..9613ef2 100644 --- a/Sample/Packages/manifest.json +++ b/Sample/Packages/manifest.json @@ -1,5 +1,8 @@ { "dependencies": { + "com.microsoft.mixedreality.toolkit.foundation": "file:MixedReality/com.microsoft.mixedreality.toolkit.foundation-2.8.2.tgz", + "com.microsoft.mixedreality.toolkit.tools": "file:MixedReality/com.microsoft.mixedreality.toolkit.tools-2.8.2.tgz", + "com.microsoft.mixedreality.toolkit.standardassets": "file:MixedReality/com.microsoft.mixedreality.toolkit.standardassets-2.8.2.tgz", "com.unity.collab-proxy": "1.17.2", "com.unity.ide.rider": "2.0.7", "com.unity.ide.visualstudio": "2.0.16", @@ -40,9 +43,6 @@ "com.unity.modules.video": "1.0.0", "com.unity.modules.vr": "1.0.0", "com.unity.modules.wind": "1.0.0", - "com.unity.modules.xr": "1.0.0", - "com.microsoft.mixedreality.toolkit.foundation": "file:MixedReality/com.microsoft.mixedreality.toolkit.foundation-2.8.2.tgz", - "com.microsoft.mixedreality.toolkit.tools": "file:MixedReality/com.microsoft.mixedreality.toolkit.tools-2.8.2.tgz", - "com.microsoft.mixedreality.toolkit.standardassets": "file:MixedReality/com.microsoft.mixedreality.toolkit.standardassets-2.8.2.tgz" + "com.unity.modules.xr": "1.0.0" } } From c28b4368c361c371d8b921f863effba9230edaad Mon Sep 17 00:00:00 2001 From: yl-msft Date: Mon, 12 Sep 2022 20:12:13 -0700 Subject: [PATCH 3/3] Preload the sample scene in Unity editor. --- Sample/ProjectSettings/ProjectSettings.asset | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sample/ProjectSettings/ProjectSettings.asset b/Sample/ProjectSettings/ProjectSettings.asset index 5f74170..a0c3aaa 100644 --- a/Sample/ProjectSettings/ProjectSettings.asset +++ b/Sample/ProjectSettings/ProjectSettings.asset @@ -135,7 +135,11 @@ PlayerSettings: 16:9: 1 Others: 1 bundleVersion: 0.1 - preloadedAssets: [] + preloadedAssets: + - {fileID: 0} + - {fileID: -6775053201470242055, guid: c7c8706914293644c9d59d2ecc25f950, type: 2} + - {fileID: 7213967213144142687, guid: 6c3d673cc4307c84ca4017f66197679d, type: 2} + - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1