Beta Release
This commit is contained in:
+119
@@ -0,0 +1,119 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace MSCO
|
||||
{
|
||||
/// <summary>
|
||||
/// Gemeinsamer Stil aller MSCO-Fenster (Launcher, F8-Konsole, Admin-Menü, Statusleiste):
|
||||
/// dunkle Flächen mit abgerundeten Ecken, orange Akzente, einheitliche Schriften und Abstände.
|
||||
/// Unitys OnGUI kennt keine runden Ecken - dafür werden kleine Texturen erzeugt und per
|
||||
/// 9-Slice (GUIStyle.border) gestreckt, sodass die Ecken rund bleiben.
|
||||
/// </summary>
|
||||
public static class UiTheme
|
||||
{
|
||||
public static readonly Color Background = Hex(0x16, 0x16, 0x1a, 0.97f);
|
||||
public static readonly Color Panel = Hex(0x0f, 0x0f, 0x12, 0.98f);
|
||||
public static readonly Color Row = Hex(0x22, 0x22, 0x28);
|
||||
public static readonly Color RowHover = Hex(0x2b, 0x2b, 0x33);
|
||||
public static readonly Color FieldColor = Hex(0x22, 0x22, 0x28);
|
||||
public static readonly Color FieldFocus = Hex(0x2c, 0x2c, 0x34);
|
||||
public static readonly Color Accent = Hex(0xf2, 0x6b, 0x1d);
|
||||
public static readonly Color AccentHover = Hex(0xff, 0x82, 0x3a);
|
||||
public static readonly Color Secondary = Hex(0x2a, 0x2a, 0x31);
|
||||
public static readonly Color SecondaryHover = Hex(0x36, 0x36, 0x3f);
|
||||
public static readonly Color Danger = Hex(0xd9, 0x44, 0x48);
|
||||
public static readonly Color DangerHover = Hex(0xee, 0x5a, 0x5e);
|
||||
public static readonly Color Text = Hex(0xf2, 0xf2, 0xf5);
|
||||
public static readonly Color Muted = Hex(0x8e, 0x8e, 0x99);
|
||||
public static readonly Color Online = Hex(0x3d, 0xd6, 0x8c);
|
||||
public static readonly Color Pending = Hex(0xf2, 0xc2, 0x1d);
|
||||
|
||||
public const int Radius = 6;
|
||||
|
||||
public static Color Hex(int r, int g, int b, float a = 1f)
|
||||
{
|
||||
return new Color(r / 255f, g / 255f, b / 255f, a);
|
||||
}
|
||||
|
||||
/// <summary>Textur mit abgerundeten Ecken (weiche Kanten) für 9-Slice-Styles.</summary>
|
||||
public static Texture2D Rounded(Color color, int radius = Radius)
|
||||
{
|
||||
int size = radius * 2 + 4;
|
||||
var tex = new Texture2D(size, size, TextureFormat.ARGB32, false);
|
||||
tex.wrapMode = TextureWrapMode.Clamp;
|
||||
tex.filterMode = FilterMode.Bilinear;
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
// Abstand zur nächsten Ecken-Mitte (innerhalb des geraden Teils = 0)
|
||||
float cx = Mathf.Clamp(x + 0.5f, radius, size - radius);
|
||||
float cy = Mathf.Clamp(y + 0.5f, radius, size - radius);
|
||||
float d = Vector2.Distance(new Vector2(x + 0.5f, y + 0.5f), new Vector2(cx, cy));
|
||||
float alpha = Mathf.Clamp01(radius - d + 0.5f);
|
||||
tex.SetPixel(x, y, new Color(color.r, color.g, color.b, color.a * alpha));
|
||||
}
|
||||
}
|
||||
tex.Apply();
|
||||
tex.hideFlags = HideFlags.HideAndDontSave;
|
||||
return tex;
|
||||
}
|
||||
|
||||
public static Texture2D Solid(Color color)
|
||||
{
|
||||
var tex = new Texture2D(1, 1);
|
||||
tex.SetPixel(0, 0, color);
|
||||
tex.Apply();
|
||||
tex.hideFlags = HideFlags.HideAndDontSave;
|
||||
return tex;
|
||||
}
|
||||
|
||||
/// <summary>Fläche (Fenster, Karte, Zeile) mit runden Ecken; mit GUI.Box zeichnen.</summary>
|
||||
public static GUIStyle Panel9(Color color, int radius = Radius)
|
||||
{
|
||||
var s = new GUIStyle();
|
||||
s.normal.background = Rounded(color, radius);
|
||||
s.border = new RectOffset(radius + 2, radius + 2, radius + 2, radius + 2);
|
||||
return s;
|
||||
}
|
||||
|
||||
public static GUIStyle Button(Color normal, Color hover, Color text, int fontSize = 13, bool bold = true)
|
||||
{
|
||||
var s = new GUIStyle(GUI.skin.button);
|
||||
s.normal.background = Rounded(normal);
|
||||
s.hover.background = Rounded(hover);
|
||||
s.active.background = Rounded(hover);
|
||||
s.focused.background = Rounded(normal);
|
||||
s.onNormal.background = Rounded(hover);
|
||||
s.normal.textColor = s.hover.textColor = s.active.textColor = s.focused.textColor = s.onNormal.textColor = text;
|
||||
s.border = new RectOffset(Radius + 2, Radius + 2, Radius + 2, Radius + 2);
|
||||
s.padding = new RectOffset(12, 12, 6, 6);
|
||||
s.fontSize = fontSize;
|
||||
s.fontStyle = bold ? FontStyle.Bold : FontStyle.Normal;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static GUIStyle Field(int fontSize = 14)
|
||||
{
|
||||
var s = new GUIStyle(GUI.skin.textField);
|
||||
s.normal.background = Rounded(FieldColor);
|
||||
s.hover.background = Rounded(FieldFocus);
|
||||
s.focused.background = Rounded(FieldFocus);
|
||||
s.normal.textColor = s.hover.textColor = s.focused.textColor = Text;
|
||||
s.border = new RectOffset(Radius + 2, Radius + 2, Radius + 2, Radius + 2);
|
||||
s.padding = new RectOffset(12, 12, 0, 0);
|
||||
s.alignment = TextAnchor.MiddleLeft;
|
||||
s.fontSize = fontSize;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static GUIStyle Label(int fontSize, Color color, FontStyle font = FontStyle.Normal, TextAnchor align = TextAnchor.UpperLeft)
|
||||
{
|
||||
var s = new GUIStyle(GUI.skin.label);
|
||||
s.fontSize = fontSize;
|
||||
s.fontStyle = font;
|
||||
s.normal.textColor = color;
|
||||
s.alignment = align;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user