A bunch of tweaks
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System.Numerics;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public static class Tools
|
||||
{
|
||||
@@ -39,4 +42,36 @@ public static class Tools
|
||||
{
|
||||
return string.Format("{0:N0}", number);
|
||||
}
|
||||
|
||||
public static void UpdateStatusText(TMP_Text statusText, string message, Color color)
|
||||
{
|
||||
statusText.text = message;
|
||||
statusText.color = color;
|
||||
}
|
||||
|
||||
public static void RenderFromBase64(string base64, Image targetImage)
|
||||
{
|
||||
byte[] imageData = Convert.FromBase64String(base64);
|
||||
Texture2D tex = new(2, 2, TextureFormat.ARGB32, false);
|
||||
if (!tex.LoadImage(imageData)) return;
|
||||
|
||||
tex.filterMode = FilterMode.Point;
|
||||
tex.Apply(false, false);
|
||||
|
||||
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new UnityEngine.Vector2(0.5f, 0.5f));
|
||||
targetImage.sprite = sprite;
|
||||
}
|
||||
|
||||
public static void RenderFromBase64(string base64, SpriteRenderer targetImage)
|
||||
{
|
||||
byte[] imageData = Convert.FromBase64String(base64);
|
||||
Texture2D tex = new(2, 2, TextureFormat.ARGB32, false);
|
||||
if (!tex.LoadImage(imageData)) return;
|
||||
|
||||
tex.filterMode = FilterMode.Point;
|
||||
tex.Apply(false, false);
|
||||
|
||||
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new UnityEngine.Vector2(0.5f, 0.5f));
|
||||
targetImage.sprite = sprite;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user