Skip to content

Commit

Permalink
Merge pull request #235 from WalletConnect/feat/customization
Browse files Browse the repository at this point in the history
feat: customization
  • Loading branch information
skibitsky authored Jul 5, 2024
2 parents 82af552 + 505d09e commit b37a4fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Packages/com.walletconnect.core/Runtime/Utils/QRCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ public class QRCode
{
public static Texture2D EncodeTexture(string textForEncoding, int width = 512, int height = 512)
{
var pixels = EncodePixels(textForEncoding, width, height);
return EncodeTexture(textForEncoding, Color.black, Color.white, width, height);
}

public static Texture2D EncodeTexture(string textForEncoding, Color fgColor, Color bgColor, int width = 512, int height = 512)
{
var pixels = EncodePixels(textForEncoding, fgColor, bgColor, width, height);

var texture = new Texture2D(width, height);
texture.SetPixels32(pixels);
Expand All @@ -20,6 +25,11 @@ public static Texture2D EncodeTexture(string textForEncoding, int width = 512, i
}

public static Color32[] EncodePixels(string textForEncoding, int width = 512, int height = 512)
{
return EncodePixels(textForEncoding, Color.black, Color.white, width, height);
}

public static Color32[] EncodePixels(string textForEncoding, Color fgColor, Color bgColor, int width = 512, int height = 512)
{
var qrCodeEncodingOptions = new QrCodeEncodingOptions
{
Expand All @@ -32,7 +42,12 @@ public static Color32[] EncodePixels(string textForEncoding, int width = 512, in
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = qrCodeEncodingOptions
Options = qrCodeEncodingOptions,
Renderer = new Color32Renderer
{
Foreground = fgColor,
Background = bgColor
}
};

return writer.Write(textForEncoding);
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.walletconnect.core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.walletconnect.core",
"version": "3.1.8",
"version": "3.1.9",
"displayName": "WalletConnectUnity Core",
"unity": "2021.3",
"changelogUrl": "https://github.com/WalletConnect/WalletConnectUnity/blob/main/Packages/com.walletconnect.core/CHANGELOG.md",
Expand Down

0 comments on commit b37a4fe

Please sign in to comment.