QRCoder.Unity icon indicating copy to clipboard operation
QRCoder.Unity copied to clipboard

Add a UIToolkit control for displaying QR codes

Open richard-fine opened this issue 1 year ago • 0 comments

This PR adds a custom UIToolkit control, which makes it easy to incorporate a QR code into a UIToolkit-based user interface.

The control is available from the UI Builder: image

You can add it and edit its properties - setting a string value, the ECC level, and the pixels-per-module for rendering, directly in the UI Builder editor:

image

or add it via UXML directly:

...
    <QRCoder.Unity.QRCodeDisplay value="https://www.google.com/" ecc-level="M" pixels-per-module="8" style="height: 300px;" />
...

and of course you can manipulate it via code like any other VisualElement:

var qrCode = uiDocument.rootVisualElement.Q<QRCoder.Unity.QRCodeDisplay>("QR_CODE");
qrCode.value = "http://github.com/";
qrCode.visible = true;

Tested in 2022.3.18f1.

richard-fine avatar Jan 29 '24 04:01 richard-fine