Experimental’s IMGUI menu is built on three helper classes that handle texture creation, style initialization, and stateful dropdown widgets. Rather than scattering magic colors and repeated style setup across every mod’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ASTRA228b/Experimental/llms.txt
Use this file to discover all available pages before exploring further.
MakeUI() method, these helpers centralize everything so the entire menu stays visually consistent and easy to extend.
GlobalTex — Solid-Color Textures
Texture2D of the given dimensions, sets the pixel at (0, 0) to the specified color via SetPixel, then calls Apply() to upload it to the GPU. Used internally by GlobalStyles to generate the background textures for every UI element.
| Parameter | Type | Description |
|---|---|---|
WW | int | Texture width in pixels |
HH | int | Texture height in pixels |
H | Color | The fill color (RGBA) |
Texture2D with SetPixel and Apply already called — ready to assign to a GUIStyle.normal.background or equivalent field.
For solid fills, a 1×1 texture is sufficient and cheapest. Unity stretches it to fill the control’s rect. Only use larger dimensions if you need the texture for something other than a uniform color fill.
GlobalStyles — Shared GUIStyle Initialization
GlobalStyles.INIT() sets up every GUIStyle used across the entire mod menu. It is called exactly once, on the first OnGUI frame, guarded by the SLoaded boolean flag in Main.
Why Lazy Initialization?
IMGUIGUIStyle objects reference textures and GUI.skin data that are only valid inside a GUI event. Creating them in Awake or Start would fail or produce incorrect results. The SLoaded flag pattern ensures INIT() runs at the earliest safe moment.
Color Scheme
All colors are defined as RGBA floats and passed throughGlobalTex.MakeTex:
| Element | Color (RGBA floats) | Visual |
|---|---|---|
| Window background | (0.1, 0.1, 0.1, 1) | Near-black |
| Slider track | (0.15, 0.15, 0.15, 1) | Dark grey |
| Slider thumb | (0.0, 0.6, 1.0, 1) | Accent blue |
| Button background | (0.2, 0.2, 0.2, 1) | Dark grey |
| Button text — normal | white | — |
| Button text — hover / active / on | blue | — |
ApplyBackground
A helper method on GlobalStyles that stamps a Texture2D onto all eight interactive states (normal, hover, active, focused, onNormal, onHover, onActive, onFocused) of a given GUIStyle at once — saving repetitive property assignment when defining a new style.
MenuHelper.Dropdown — Stateful Dropdown Widget
The built-in IMGUI toolkit has no native dropdown control. MenuHelper.Dropdown fills that gap with a stateful dropdown that tracks its own open/closed state in a static dictionary keyed by a string ID.
Signature
| Parameter | Type | Description |
|---|---|---|
id | string | Unique identifier for this dropdown’s open/close state. Must be distinct per dropdown on screen. |
options | string[] | Array of display labels, one per option. |
selectedIndex | int | The currently selected option index. |
layout | GUILayoutOption[] | Optional layout options (e.g., GUILayout.Width(200)). |
selectedIndex — either the same value if no change was made, or the index of whichever option the player clicked.
How It Works
Internally,Dropdown maintains a static Dictionary<string, bool> that maps each id to whether that dropdown is currently expanded. On each OnGUI call:
- Renders a main button labeled with
options[selectedIndex]. - If the dictionary marks this
idas open, renders a button for every entry inoptionsbelow the main button inside aGUILayout.BeginVerticalblock. - Clicking an option button closes the dropdown and returns that option’s index.
- Clicking the main button again toggles it closed without changing the selection.