MirzkisD1Ex0 2 rokov pred
rodič
commit
e117d4e93c

+ 34 - 3
ToneTuneToolkit/Assets/ToneTuneToolkit/Scripts/Other/QRCodeMaster.cs

@@ -9,6 +9,9 @@ using UnityEngine.Networking;
 
 using ToneTuneToolkit.Common;
 using ZXing;
+using ZXing.Common;
+using UnityEngine.UIElements;
+using FordVRAdventure;
 
 namespace ToneTuneToolkit.Other
 {
@@ -19,11 +22,15 @@ namespace ToneTuneToolkit.Other
   {
     public static QRCodeMaster Instance;
 
+    // ==================================================
+
     private void Awake()
     {
       Instance = this;
     }
 
+    // ==================================================
+
     public void GetQRContent(string url)
     {
       StartCoroutine(GetQRPicture(url));
@@ -43,13 +50,13 @@ namespace ToneTuneToolkit.Other
 
       if (webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
       {
-        TipTools.Error(webRequest.error);
+        Debug.Log(webRequest.error);
         yield break;
       }
       Texture2D texture = DownloadHandlerTexture.GetContent(webRequest);
 
       string result = DecodeQRCode(texture);
-      TipTools.Notice($"[QRCodeHelper] Result is [{result}], from [{url}].");
+      Debug.Log($"[QRCodeHelper] Result is [{result}], from [{url}].");
       yield break;
     }
 
@@ -67,10 +74,34 @@ namespace ToneTuneToolkit.Other
       Result result = barcodeReader.Decode(texture.GetPixels32(), texture.width, texture.height);
       if (result == null)
       {
-        TipTools.Error("[QRCodeHelper] Decode failed.");
+        Debug.Log("[QRCodeHelper] Decode failed.");
         return null;
       }
       return result.Text;
     }
+
+    /// <summary>
+    /// 形成二维码
+    /// </summary>
+    /// <param name="qrText"></param>
+    /// <param name="qrWidth"></param>
+    /// <param name="qrHeight"></param>
+    /// <returns></returns>
+    public Texture2D GenerateQRCode(string qrText, int qrWidth, int qrHeight)
+    {
+      BarcodeWriter writer = new BarcodeWriter();
+      writer.Format = BarcodeFormat.QR_CODE;
+      writer.Options.Width = qrWidth;
+      writer.Options.Height = qrHeight;
+      writer.Options.Hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
+
+      Color32[] colors = writer.Write(qrText);
+
+      Texture2D qrTexture = new Texture2D(qrWidth, qrHeight);
+      qrTexture.SetPixels32(colors);
+      qrTexture.Apply();
+
+      return qrTexture;
+    }
   }
 }

+ 1 - 0
ToneTuneToolkit/Logs/AssetImportWorker0.log

@@ -154,3 +154,4 @@ Received Import Request.
   path: Assets/ToneTuneToolkit/Scripts/Editor/CreateAssetBundles.cs
   artifactKey: Guid(4ed1ab1447390554aaaf09c73660763a) Importer(815301076,1909f56bfc062723c751e8b465ee728b)
 Start importing Assets/ToneTuneToolkit/Scripts/Editor/CreateAssetBundles.cs using Guid(4ed1ab1447390554aaaf09c73660763a) Importer(815301076,1909f56bfc062723c751e8b465ee728b)  -> (artifact id: '896e3fe831d8f7c81c5ead0ac6d6489a') in 0.004277 seconds 
+AssetImportWorkerClient::OnTransportError - code=2 error=End of file

+ 3 - 0
ToneTuneToolkit/Logs/shadercompiler-AssetImportWorker0.log

@@ -1,3 +1,6 @@
 Base path: 'C:/Workflow/Software/Unity/2020.3.48f1c1/Editor/Data', plugins path 'C:/Workflow/Software/Unity/2020.3.48f1c1/Editor/Data/PlaybackEngines'
 Cmd: initializeCompiler
 
+Unhandled exception: Protocol error - failed to read magic number (error -2147483644, transferred 0/4)
+
+Quitting shader compiler process

+ 3 - 0
ToneTuneToolkit/Logs/shadercompiler-UnityShaderCompiler.exe0.log

@@ -1,3 +1,6 @@
 Base path: 'C:/Workflow/Software/Unity/2020.3.48f1c1/Editor/Data', plugins path 'C:/Workflow/Software/Unity/2020.3.48f1c1/Editor/Data/PlaybackEngines'
 Cmd: initializeCompiler
 
+Cmd: shutdown
+
+Quitting shader compiler process