Android-native QR scanner plugin for Unity. Wraps Google ML Kit's barcode scanner — the same decoder Android's stock Camera app uses.
Replaces ZXing.NET in Unity Android projects that need production-grade QR decoding (handles perspective distortion, low contrast, slight blur, custom-designed QRs — the cases ZXing.NET fails on).
CI builds the AAR on every push. To build locally:
gradle :library:assembleReleaseOutput: library/build/outputs/aar/library-release.aar.
(If you don't have Gradle installed system-wide, run gradle wrapper once to generate ./gradlew.)
- Drop
library-release.aarintoAssets/Plugins/Android/. - Drop
unity/MLKitQRScanner.csinto your Unity project (or copy its contents). - Either commit
unity/Dependencies.xmlto your project (so External Dependency Manager auto-resolves the ML Kit dependency), or add this line manually to yourmainTemplate.gradle:
implementation 'com.google.mlkit:barcode-scanning:17.3.0'- Call from C#:
using XRProj.QRScanner;
byte[] grayscaleBuffer = ...; // R8 / Gray8 single-channel
int width = 640, height = 480;
MLKitQRScanner.Scan(grayscaleBuffer, width, height, result =>
{
if (result != null)
Debug.Log($"QR decoded: {result}");
else
Debug.Log("no QR found in frame");
});ZXing.NET (the .NET port still floating around in Unity projects) is in slow maintenance and struggles with real-world handheld captures. ML Kit's barcode scanner is what Google ships in production camera apps — actively developed, hardware-accelerated where available, and far more tolerant of imperfect input.
For an apples-to-apples test, scan the same poorly-lit QR with this plugin vs ZXing.NET; ML Kit reads it, ZXing returns null.