Thanks Shayne, this code saved my project.
The code is outdated though if you are using OpenXR. There's now a better way to compute the QR Code's pose. For QRCodeInformation, I'm adding another field called "SpatialGraphNodeID":
public class QRCodeInformation
{
public string Data { get; set; }
public float Length { get; set; }
#if WINDOWS_UWP
public SpatialCoordinateSystem QRSpatialCoordinateSystem { get; set; }
public Guid SpatialGraphNodeID { get; set; }
public QRCodeInformation(string data, SpatialCoordinateSystem qrSpatialCoordinateSystem, float length, Guid spatialGraphNodeID)
{
Data = data;
Length = length;
QRSpatialCoordinateSystem = qrSpatialCoordinateSystem;
SpatialGraphNodeID = spatialGraphNodeID;
}
#endif
public QRCodeInformation() { }
}
I had to change some code to match the new constructor's signature.
Then, to find the pose, I use this code instead:
SpatialGraphNode node = SpatialGraphNode.FromStaticNodeId(SpatialGraphNodeID);
Pose pose;
if (node != null && node.TryLocate(FrameTime.OnUpdate, out pose))
{
if (CameraCache.Main.transform.parent != null)
{
pose = pose.GetTransformedBy(CameraCache.Main.transform.parent);
}
marker.transform.SetPositionAndRotation(pose.position, pose.rotation);
}
This snippet is from: Microsoft' QR Source Code
I hate making public posts very much. However, I think this would be a very good PSA for anyone who's about to go Kylo Ren on their equipment.
PS: I could clean up your code to remove any WinRT reference too, but I just have no fight left at the moment.