It is necessary to generate a QR code from the text. I'm using the ZXing.unity.dll library
using ZXing;
using ZXing.QrCode;
Generating QR code
private static Color32[] Encode(string textForEncoding, int width, int height) {
var writer = new BarcodeWriter {
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions{
Height = height,
Width = width
}
};
return writer.Write(textForEncoding);
}
public Texture2D generateQR(string text) {
var encoded = new Texture2D (256, 256);
var color32 = Encode(text, encoded.width, encoded.height);
encoded.SetPixels32(color32);
encoded.Apply();
return encoded;
}
Applying the generated QR to the RawImage filled in the field
public RawImage RI;
...
RI.texture = generateQR("https://test.link/123");
The output is a picture with large white edges.
- Q1 - How to remove white edges;
- Q2 - How to make a transparent background;
- Q3 - How to change black color to any other