using System; using TMPro; using UnityEngine; using UnityEngine.UI; namespace Olympus { public static class OlympusUi { public static TMP_FontAsset Font; // Selected art direction A: warm temple, carved wood, champagne gold. public static Color Background=new Color32(14,9,6,255), Panel=new Color32(41,27,14,255), Gold=new Color32(247,200,96,255), Ink=new Color32(255,247,230,255); public static RectTransform Rect(string name,Transform parent) { var go=new GameObject(name,typeof(RectTransform)); go.transform.SetParent(parent,false);return (RectTransform)go.transform; } public static void Fill(RectTransform rect,float inset=0) { rect.anchorMin=Vector2.zero;rect.anchorMax=Vector2.one;rect.offsetMin=Vector2.one*inset;rect.offsetMax=Vector2.one*-inset; } public static Image Box(string name,Transform parent,Color color) { var r=Rect(name,parent);var image=r.gameObject.AddComponent();image.color=color;return image; } public static TextMeshProUGUI Text(string name,Transform parent,string value,float size=26,TextAlignmentOptions alignment=TextAlignmentOptions.Center) { var r=Rect(name,parent);var t=r.gameObject.AddComponent();t.font=Font;t.text=value;t.fontSize=size;t.color=Ink;t.alignment=alignment;t.raycastTarget=false;t.textWrappingMode=TextWrappingModes.Normal;r.gameObject.AddComponent().flexibleWidth=1;return t; } public static void Height(Component c,float value) { var l=c.GetComponent()??c.gameObject.AddComponent();l.minHeight=value;l.preferredHeight=value;l.flexibleHeight=0; } public static void Flex(Component c) { var l=c.GetComponent()??c.gameObject.AddComponent();l.flexibleHeight=1;l.minHeight=20; } public static VerticalLayoutGroup Column(Transform parent,float spacing=12,int padding=16) { var g=parent.gameObject.AddComponent();g.spacing=spacing;g.padding=new RectOffset(padding,padding,padding,padding); g.childControlWidth=g.childControlHeight=true;g.childForceExpandWidth=true;g.childForceExpandHeight=false;return g; } public static RectTransform Row(string name,Transform parent,float height=60,float spacing=8) { var r=Rect(name,parent);Height(r,height);var g=r.gameObject.AddComponent();g.spacing=spacing;g.childControlWidth=g.childControlHeight=true;g.childForceExpandWidth=false;g.childForceExpandHeight=true;return r; } public static Button Button(Transform parent,string value,Action action,float height=62) { var box=Box(value,parent,Color.white);box.sprite=Resources.Load("Olympus/Elements/v3_button");box.type=Image.Type.Sliced;if(!box.sprite)box.color=Panel; Height(box,height); box.gameObject.AddComponent().capsule=true; box.GetComponent().flexibleWidth=1; var b=box.gameObject.AddComponent