Skip to content

Commit eb650ab

Browse files
committed
.NET 2.2.0 & QR Helper
1 parent 2f1e89f commit eb650ab

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed

Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
%TAG !u! tag:unity3d.com,2011:
33
--- !u!21 &2180264
44
Material:
5-
serializedVersion: 6
5+
serializedVersion: 8
66
m_ObjectHideFlags: 0
77
m_CorrespondingSourceObject: {fileID: 0}
88
m_PrefabInstance: {fileID: 0}
99
m_PrefabAsset: {fileID: 0}
1010
m_Name: LiberationSans SDF Material
1111
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
12-
m_ShaderKeywords:
12+
m_Parent: {fileID: 0}
13+
m_ModifiedSerializedProperties: 0
14+
m_ValidKeywords: []
15+
m_InvalidKeywords: []
1316
m_LightmapFlags: 1
1417
m_EnableInstancingVariants: 0
1518
m_DoubleSidedGI: 0
1619
m_CustomRenderQueue: -1
1720
stringTagMap: {}
1821
disabledShaderPasses: []
22+
m_LockedProperties:
1923
m_SavedProperties:
2024
serializedVersion: 3
2125
m_TexEnvs:
@@ -67,6 +71,7 @@ Material:
6771
m_Texture: {fileID: 0}
6872
m_Scale: {x: 1, y: 1}
6973
m_Offset: {x: 0, y: 0}
74+
m_Ints: []
7075
m_Floats:
7176
- _Ambient: 0.5
7277
- _Bevel: 0.5
@@ -148,6 +153,7 @@ Material:
148153
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
149154
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
150155
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
156+
m_BuildTextureStacks: []
151157
--- !u!114 &11400000
152158
MonoBehaviour:
153159
m_ObjectHideFlags: 0
@@ -160,18 +166,21 @@ MonoBehaviour:
160166
m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
161167
m_Name: LiberationSans SDF - Fallback
162168
m_EditorClassIdentifier:
169+
hashCode: -1699145518
170+
material: {fileID: 0}
171+
materialHashCode: 462855346
163172
m_Version: 1.1.0
164-
m_Material: {fileID: 2180264}
165173
m_SourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
174+
m_SourceFontFile_EditorRef: {fileID: 0}
166175
m_SourceFontFile: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3}
167176
m_AtlasPopulationMode: 1
168-
InternalDynamicOS: 0
169177
m_FaceInfo:
170178
m_FaceIndex: 0
171179
m_FamilyName: Liberation Sans
172180
m_StyleName: Regular
173181
m_PointSize: 86
174182
m_Scale: 1
183+
m_UnitsPerEM: 0
175184
m_LineHeight: 98.8916
176185
m_AscentLine: 77.853516
177186
m_CapLine: 59
@@ -231,21 +240,15 @@ MonoBehaviour:
231240
m_KerningTable:
232241
kerningPairs: []
233242
m_FontFeatureTable:
234-
m_MultipleSubstitutionRecords: []
235-
m_LigatureSubstitutionRecords: []
236243
m_GlyphPairAdjustmentRecords: []
237-
m_MarkToBaseAdjustmentRecords: []
238-
m_MarkToMarkAdjustmentRecords: []
239244
fallbackFontAssets: []
240245
m_FallbackFontAssetTable: []
241246
m_CreationSettings:
242247
sourceFontFileName:
243248
sourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
244-
faceIndex: 0
245249
pointSizeSamplingMode: 0
246250
pointSize: 86
247251
padding: 9
248-
paddingMode: 0
249252
packingMode: 4
250253
atlasWidth: 512
251254
atlasHeight: 512
@@ -317,15 +320,21 @@ Texture2D:
317320
Hash: 00000000000000000000000000000000
318321
m_ForcedFallbackFormat: 4
319322
m_DownscaleFallback: 0
323+
m_IsAlphaChannelOptional: 0
320324
serializedVersion: 2
321325
m_Width: 0
322326
m_Height: 0
323327
m_CompleteImageSize: 0
328+
m_MipsStripped: 0
324329
m_TextureFormat: 1
325330
m_MipCount: 1
326331
m_IsReadable: 1
332+
m_IsPreProcessed: 0
333+
m_IgnoreMipmapLimit: 0
334+
m_MipmapLimitGroupName:
327335
m_StreamingMipmaps: 0
328336
m_StreamingMipmapsPriority: 0
337+
m_VTOnly: 0
329338
m_AlphaIsTransparency: 0
330339
m_ImageCount: 1
331340
m_TextureDimension: 2
@@ -339,9 +348,11 @@ Texture2D:
339348
m_WrapW: 0
340349
m_LightmapFormat: 0
341350
m_ColorSpace: 0
351+
m_PlatformBlob:
342352
image data: 0
343353
_typelessdata:
344354
m_StreamData:
355+
serializedVersion: 2
345356
offset: 0
346357
size: 0
347358
path:
9 KB
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/ThirdwebUnityExtensions.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Numerics;
22
using System.Threading.Tasks;
33
using UnityEngine;
4+
using ZXing;
5+
using ZXing.QrCode;
46

57
namespace Thirdweb.Unity
68
{
@@ -25,5 +27,36 @@ public static async Task<SmartWallet> UpgradeToSmartWallet(this IThirdwebWallet
2527
{
2628
return await ThirdwebManager.Instance.UpgradeToSmartWallet(personalWallet, chainId, smartWalletOptions);
2729
}
30+
31+
public static Texture2D ToQRTexture(this string textForEncoding, Color? fgColor = null, Color? bgColor = null, int width = 512, int height = 512)
32+
{
33+
fgColor ??= Color.black;
34+
bgColor ??= Color.white;
35+
36+
var qrCodeEncodingOptions = new QrCodeEncodingOptions
37+
{
38+
Height = height,
39+
Width = width,
40+
Margin = 4,
41+
QrVersion = 11
42+
};
43+
44+
var writer = new BarcodeWriter
45+
{
46+
Format = BarcodeFormat.QR_CODE,
47+
Options = qrCodeEncodingOptions,
48+
Renderer = new Color32Renderer { Foreground = fgColor.Value, Background = bgColor.Value }
49+
};
50+
51+
var pixels = writer.Write(textForEncoding);
52+
53+
var texture = new Texture2D(width, height);
54+
texture.SetPixels32(pixels);
55+
texture.filterMode = FilterMode.Point;
56+
texture.Apply();
57+
texture.Compress(true);
58+
59+
return texture;
60+
}
2861
}
2962
}

0 commit comments

Comments
 (0)