For the complete documentation index, see llms.txt. This page is also available as Markdown.

Show a QR code in world space

Generating a QR Code Texture for UI

using Tebex.QR;
using Tebex.TebexUnity;
using UnityEngine;
using UnityEngine.UI;

public class CheckoutQR : MonoBehaviour
{
    [SerializeField] RawImage qrDisplayImage;

    public void ShowCheckoutQR(string checkoutUrl)
    {
        // Encode the URL into a QR code (HTTPS only).
        QrCode qr = QrCode.Encode(checkoutUrl);

        // Convert to Texture2D with a scale of 8px per module and a 4-module quiet zone.
        Texture2D qrTexture = Utilities.QrToTexture(qr, scale: 8, quietZone: 4);

        // Assign to a RawImage UI element.
        qrDisplayImage.texture = qrTexture;
    }
}

Last updated

Was this helpful?