Files
MSCO/Branding.cs
T
2026-09-26 19:37:28 +02:00

51 lines
1.6 KiB
C#

using System.IO;
using System.Reflection;
using UnityEngine;
namespace MSCO
{
/// <summary>
/// MSCO-Logo (branding/logo-128.png, als Ressource in die DLL eingebettet):
/// Symbol in der MSCLoader-Modliste und im Launcher.
/// </summary>
public static class Branding
{
const string LogoResource = "MSCO.logo.png";
static byte[] logoPng;
static Texture2D logoTexture;
public static byte[] LogoPng
{
get
{
if (logoPng != null) return logoPng;
using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(LogoResource))
{
if (s == null) return logoPng = new byte[0];
var data = new byte[s.Length];
int read = 0;
while (read < data.Length) read += s.Read(data, read, data.Length - read);
logoPng = data;
}
return logoPng;
}
}
/// <summary>Logo als Textur für OnGUI (nur im Hauptthread verwenden).</summary>
public static Texture2D LogoTexture
{
get
{
if (logoTexture != null) return logoTexture;
if (LogoPng.Length == 0) return null;
logoTexture = new Texture2D(2, 2, TextureFormat.ARGB32, false);
logoTexture.LoadImage(LogoPng);
logoTexture.filterMode = FilterMode.Bilinear;
logoTexture.hideFlags = HideFlags.HideAndDontSave;
return logoTexture;
}
}
}
}