Mega UI
API reference
Every public type, member and field, on one page.
Namespace MegaUI.Api. Everything else in the assembly is internal and
is not a contract — see Versioning.
MegaUiApi
| Member | Type | What it does |
|---|---|---|
ModGuid | const string | "MegaUI". Use it in your [BepInDependency]. |
ApiVersion | static readonly int | The contract version. Moves only on a breaking change. |
Register(guid, definition) | AppHandle | Puts your app on the desktop. Never throws, never returns null. |
Unregister(guid) | bool | Takes it off again. The apps below move up. |
IsRegistered(guid) | bool | Whether that guid currently has an app. |
BuiltinIcons | IEnumerable<string> | The names accepted by UiIcon.Builtin. |
AppDefinition
| Field | Type | Default | What it does |
|---|---|---|---|
Title | string | the guid | Label under the icon and on the tab. Cut at 18 characters. |
Icon | UiIcon | monitor | The desktop icon. |
SortOrder | int | 0 | Position in the column, low first. Ties break by guid. |
OnOpened | Action | null | After the window becomes visible. |
OnClosed | Action | null | On minimize, close, or walking away. |
AppHandle
| Member | Type | What it does |
|---|---|---|
Ok | bool | False when the registration was refused. |
Problem | string | Why it was refused, or null. |
Build(action) | AppHandle | Describes the screen. Returns itself, so it chains. |
Refresh() | void | Rebuilds the screen because its shape changed. |
Every member is safe to call on a refused handle, so the happy path needs no guard.
UiIcon
| Member | What it does |
|---|---|
UiIcon.Builtin(name) | One of the bundled icons. Unknown names fall back to monitor. |
UiIcon.FromPng(bytes) | Your own PNG, as bytes. Square looks best. |
IUiBuilder
What Build hands you. Things stack down the window in the order you add them.
| Method | What it adds |
|---|---|
Header(string) | A section title. |
Label(string) | Plain text. |
Value(Func<string>) | Text re-read on every open. |
Note(string) | Small dim text explaining the control above it. |
Button(string, Action) | A full-width button. |
Toggle(string, Func<bool>, Action<bool>) | A checkbox. |
Stepper(string, int, int, Func<int>, Action<int>) | A number with − and +. Clamped for you. |
Slider(string, float, float, Func<float>, Action<float>) | A continuous value, with the reading beside it. |
Dropdown(string, string[], Func<int>, Action<int>) | One of a short list. Opens above the window. |
TextField(string, Func<string>, Action<string>) | Typing. Holds the keyboard while focused; sets on end of edit. |
Stats(params (string, Func<string>)[]) | A row of big numbers with captions. |
ProgressBar(string, Func<float>) | A bar. The fraction is clamped for you. |
Image(string, byte[], float) | Built-in icon or your PNG, full width. |
Tabs(string[], Func<int>, Action<int>) | A row of tabs. You decide what each one shows. |
List(string[], Func<int>, Action<int>) | A pickable list, with optional icons. |
Columns(params Action<IUiBuilder>[]) | Builders side by side, sharing the width. |
Separator() | A horizontal line. |
Gap(float) | Vertical space. 12 pixels by default. |
Row(Action<IUiRow>) | A line laid out left to right. |
Card(Action<IUiBuilder>) | A panel that sizes itself to its contents. |
Diagram(float, Action<IUiDiagram>, bool) | Free positioning. bleed runs it edge to edge. |
Raw(float) | A positioned rectangle of the right width. Yours. |
Area | The visible area in pixels, for sizing something to the window. |
Font | The game's TMP font, for anything you draw yourself. |
Every colour is an optional parameter on the widget that uses it. See Look and feel.
IUiDiagram
What Diagram and Region hand you. Origin at the top-left, y downwards.
| Method | What it draws |
|---|---|
Node(float, float, ...) | A disc with a ring, an icon and a level. Every state colour can be overridden. |
Link(float, float, float, float, ...) | A connector. Straight lines join without gaps. |
Text(float, float, string, ...) | Free text, with UiAlign and optional shrink-to-fit. |
Box(float, float, float, float, ...) | A filled rectangle, optionally rounded. |
Button(float, float, float, float, ...) | A button at an exact spot. Its label shrinks to fit by default. |
Image(float, float, float, float, ...) | Built-in icon or your PNG. |
Region(float, float, float, float, ..., pan) | A clipped sub-surface, optionally draggable and zoomable. |
Raw(float, float, float, float) | A positioned rectangle. Yours. |
Size / Theme | The surface size, and the colours in force. |
IUiRow
| Method | What it adds |
|---|---|
Label(string) | Text, sized to what it contains. |
Value(Func<string>) | Text re-read on every open, resized as it changes. |
Button(string, Action) | A button sized to its text. |
Icon(string) | A built-in icon at row height. |
Spacer() | Everything after it anchors to the right edge. |
Gap(float) | Horizontal space. 8 pixels by default. |
Things that are true of all of it
- Nothing throws at you. A refusal is a return value, never an exception.
- Your callbacks are wrapped. A throw inside one is logged with your guid and swallowed.
- You never pass a coordinate — unless you asked for a diagram, where placing things is the whole point.
- Every colour is optional. Nothing is forced; the theme is the default.
- Every
Funcis read again on every open.