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

MemberTypeWhat it does
ModGuidconst string"MegaUI". Use it in your [BepInDependency].
ApiVersionstatic readonly intThe contract version. Moves only on a breaking change.
Register(guid, definition)AppHandlePuts your app on the desktop. Never throws, never returns null.
Unregister(guid)boolTakes it off again. The apps below move up.
IsRegistered(guid)boolWhether that guid currently has an app.
BuiltinIconsIEnumerable<string>The names accepted by UiIcon.Builtin.

AppDefinition

FieldTypeDefaultWhat it does
Titlestringthe guidLabel under the icon and on the tab. Cut at 18 characters.
IconUiIconmonitorThe desktop icon.
SortOrderint0Position in the column, low first. Ties break by guid.
OnOpenedActionnullAfter the window becomes visible.
OnClosedActionnullOn minimize, close, or walking away.

AppHandle

MemberTypeWhat it does
OkboolFalse when the registration was refused.
ProblemstringWhy it was refused, or null.
Build(action)AppHandleDescribes the screen. Returns itself, so it chains.
Refresh()voidRebuilds the screen because its shape changed.

Every member is safe to call on a refused handle, so the happy path needs no guard.

UiIcon

MemberWhat 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.

MethodWhat 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.
AreaThe visible area in pixels, for sizing something to the window.
FontThe 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.

MethodWhat 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 / ThemeThe surface size, and the colours in force.

IUiRow

MethodWhat 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