Search code examples
c#unity-game-engineaugmented-realityqr-codehololens

implementing QR code scanning on a unity HoloLens2 app


I am trying to implement QR code scanning for my Hololens2 AR app on unity and I can't seem to figure it out. There is Microsoft documentation here (https://learn.microsoft.com/en-us/windows/mixed-reality/develop/platform-capabilities-and-apis/qr-code-tracking), but this documentation does not show how to implement using C# scripts (which is what would be ideal). It points to a confusing example project which does not run on my end. I have looked around and can not seem to find any helpful guides for implementing this.

If anyone has done this before or knows how to, could you help out?


Solution

  • Create a brand new MixedReality project, copy the scripts and prefabs from that project, add a GameObject to your scene (e.g. QRCodeManager) and attach QRCodeManager.cs and QRCodeHandler.cs to it. You can tick "Auto Start QR Tracking" in QRCodesManager (in Unity Editor) in order to start scanning for QRCodes by default. QRCodesVisualizer.cs deals with QRCode detection events (HandleEvents()). If you are using the scripts as they are, as soon as a QRCode is detected you will have a visual confirmation.