unity-game-engineqr-codehololenswindows-mixed-reality

Newbie question for trying to get the location of a QR Code with hololens 2


I am trying to use this sample project to set up QR Code tracking for Hololens: https://github.com/microsoft/MixedReality-QRCode-Sample/blob/main

I think I am getting close, but I am running into a couple of issues. Basically, my theory is that my scene is set up wrong, and/or the branch I'm getting the code from ("main") is not the correct one and I should be using "OpenXR". When I play, the hololens properly detects the QR Code, its version, physical scale and stuff like that from the QRCode.cs script. However, it will not get the location from the SpatialGraphNode.cs and SpatialGraphNodeTrack.cs scripts.

What I have found is that the SpatialGraphNodeTracker.cs script is trying to assign a variable "node" in Update() to "SpatialGraphNode.FromStaticNodeId(Id)". However, SpatialGraphNode has a test that looks like: #if WINDOWS_UWP && UNITY_XR_WINDOWSMR. I have never seen an if statement like this in C# and I don't actually know where it is getting the WINDOWS_UDP and UNITY_XR_WINDOWSMR values from, but I am pretty sure they are both false as I have done some testing. This means that the "node" variable from earlier is being assigned as null and therefore I can't get a pose from it.

I have tried copy and pasting the SpatialGraphNodeTracker script out of the "OpenXR" branch in Github into my unity scene (which is using the "main" branch) and I didn't get any errors, but the same issue persisted. That's why my theory is that my scene is set up incorrectly. The values WINDOWS_UDP UNITY_XR_WINDOWSMR and MIXED_REALITY_OPENXR are all false when I tested them. I am in Unity version 2021.3.33f1 if that helps.

Sorry for this huge block of text, but I really don't know where to go from here. Thanks in advance!


Solution

  • I had the exact same issue you were running into. Just finally fixed it, you need to switch to the other branch in the Github repository (OpenXR). If you download that branch instead of main that problem should be fixed.