using System.IO; using System; using PrizeSystem; using UnityEngine; using QRCoder; public static class QrMaker { // Возвращает Texture2D для UI/материалов public static Texture2D MakeTexture(string text, int pixelsPerModule = 1, bool drawQuietZones = true) { using var gen = new QRCodeGenerator(); using var data = gen.CreateQrCode(text, QRCodeGenerator.ECCLevel.M); var png = new PngByteQRCode(data); // Генерим PNG-байты без System.Drawing byte[] bytes = png.GetGraphic(pixelsPerModule); var tex = new Texture2D(2, 2, TextureFormat.RGBA32, false); tex.LoadImage(bytes); // раскодирует PNG → RGBA tex.Apply(false, false); return tex; } public static Texture2D MakePrizeTexture(QrPrize prize, int pixelsPerModule = 1) => MakeTexture(MakePrizeUrl(prize), pixelsPerModule); public static string MakePrizeUrl(QrPrize prize) { string message = $"Здравствуйте! Я победил на аппарате {PlayerPrefs.GetString("Serial")}. Жду приз!" + $" Дата выигрыша: {DateTime.Now:dd.MM.yyyy HH:mm}. " + $"Приз: {prize.PrizeText}"; string administrationNumber = PlayerPrefs.GetString(PrefsKeyVault.NUMBER_ADMIN); return $"https://t.me/+{administrationNumber}?text={Uri.EscapeDataString(message)}"; } }