Tabs, rows & layout
Where an option appears and how much space it takes: tabs, categories, ordering, side-by-side rows, heights and icons.
Tabs and categories
Options live in a tab and, within it, a category.
InTab and InCategory place them; without
either, options land in the Options tab under
General - flat usage stays a one-liner:
DMD.Options.AddToggle("God Mode", () => _god, v => _god = v)
.InTab("Player").InCategory("Combat");
DMD.Options.AddInt("One-Shot Damage", () => _damage, v => _damage = v)
.WithRange(1, 9999)
.InTab("Player").InCategory("Combat");
DMD.Options.AddInt("Coins", () => _coins, v => _coins = v)
.InTab("Player").InCategory("Economy");
Tabs and categories exist as soon as one option names them and disappear when their last option is removed. Passing null or an empty string reverts to the default tab or category.
Sub tabs
A big panel can nest tabs. Pass sub tab names after the tab, outermost first - up to three levels under a tab, as many sub tabs per level as you like:
DMD.Options.AddToggle("God Mode", () => _god, v => _god = v)
.InTab("Game", "Combat", "Cheats");
DMD.Options.AddButton("Spawn Boss", SpawnBoss)
.InTab("World", "Spawning", "Enemies", "Bosses");
DMD.Options.AddFloat("Time Of Day", () => _time, v => _time = v)
.InTab("World"); // lands in World > General
- Each level gets its own tab bar under its parent, for the path you have selected. A level with a single entry hides its bar, like a lone top-level tab does.
- A tab that holds sub tabs shows a small down chevron after its name, so nested levels are visible before you open it. Turn the markers off with Sub Tab Markers in the settings, or per device on the About page.
- Each level has its own color, set by the theme (see theming).
- A tab with options of its own and sub tabs shows its own options in a first sub tab named General.
- The panel remembers the sub tab you left each tab on.
- Search covers sub tab names too, and result headers show the full path.
- More than three levels logs a warning and the deeper names are ignored. The path ends at the first null or empty name.
Tab icons
Tabs come into being from option paths, so an icon is declared once
per tab rather than on every option. Name the tab the way
InTab does, outermost first:
DMD.Options.SetTabIcon(DmdIcon.Cottage, "Camp"); // top-level tab
DMD.Options.SetTabIcon(DmdIcon.AddBox, "Camp", "Spawn"); // sub tab
DMD.Options.SetTabIcon("Icons/Coin", "Wallet"); // your own image
- The icon sits before the name, in the tab's own text color, so it follows the theme and the active state. Images render full-color, from a Resources path as for option images.
- Call it before or after the options that create the tab. An icon for a tab that never appears does nothing.
- Any level takes one, including the implicit General
sub tab, by name:
SetTabIcon(icon, "World", "General"). - Icons belong to the registry, not to scopes or owners: removing
options leaves the icon in place for when the tab comes back. Pass
DmdIcon.None(or a null path) to remove one. DMDEditor.Optionshas the same method for the editor window's tabs.- Tabs without an icon look as they always have. The bar wraps onto more lines when the tabs do not fit, so a crowded bar never cuts a tab off; there is no icon-only mode.
Ordering
Within a category, WithOrder sorts options - lower
values first:
DMD.Options.AddButton("Save", SaveGame).WithOrder(0);
DMD.Options.AddButton("Load", LoadGame).WithOrder(1);
DMD.Options.AddButton("Wipe Save", WipeSave).WithOrder(99);
Side-by-side rows
Options render one per line by default. InRow(key) lays
an option out side by side with every option sharing the same row key
within its tab and category. WithWidth declares how much of
the row a member takes - as a percentage, never pixels,
so layouts survive UI scaling:
// A live gold readout with its grant button on the same line, 70/30.
DMD.Options.AddInfo("Gold", () => _gold.ToString())
.InTab("Game").InCategory("Economy")
.InRow("gold").WithWidth(70f);
DMD.Options.AddButton("Grant 500", () => _gold += 500)
.InTab("Game").InCategory("Economy")
.InRow("gold").WithWidth(30f).WithOrder(1);
The rules, in the order they matter:
- Members without a declared width share the remaining space
equally.
WithWidthvalues above 100 clamp to 100; zero or below reverts to equal sharing. - Members that don't fit - including declared widths adding up past 100% - wrap onto a new line inside the row.
- A wide member (text field, picker or number) too narrow for its label moves the labels of its whole line above their controls instead of shrinking the text - see Labels.
- On a panel too narrow to share - any member would get under about 140 reference pixels (90 for a button) - the row gives up sharing and every member takes a line of its own, lined up with the full-width rows around it. Widen the panel and the row comes back.
- Two or three members per row is the comfortable maximum on a phone.
- Pinned options ignore rows and stay a single column.
Heights
WithHeight sets an option's height in reference pixels -
the value scales with the panel's UI scale, so proportions hold across
resolutions. Values under the panel's minimum row height are raised to
it:
// A big, hard-to-miss restart button.
DMD.Options.AddButton("Restart Run", RestartRun)
.WithHeight(56f)
.InRow("run");
DMD.Options.AddButton("Abandon", AbandonRun)
.InRow("run").WithOrder(1);
In a shared row, the tallest member sets the line height; the others keep their own height and align to the top - except buttons without a declared height, which grow to fill the line. In the sample above, Abandon matches Restart Run at 56 pixels without declaring anything.
Labels
A label sits beside its control and stays on one line. One too long for its space ends in "..." rather than making the row taller; tap or click it to read the whole thing in a small bubble. A tap anywhere closes the bubble again, and a press outside it still reaches whatever is underneath, so you can keep scrolling. Info values, button captions and category titles wrap onto more lines instead.
Without a declaration, wide controls pick the label position from the row's width. Text fields and pickers move their label above the control when the row is narrower than about 420 reference pixels, numbers when it is narrower than about 290; everything else keeps the label beside.
WithLabelAbove fixes the position instead.
WithLabelAbove() moves the label above the control, which
then gets the full width of the row - handy for a long label, or for a
control that wants the room. WithLabelAbove(false) keeps it
beside at any width. Declaring either way turns the automatic choice off
for that option:
DMD.Options.AddFloat("Camera Shake Intensity", () => _shake, v => _shake = v)
.WithRange(0f, 1f)
.WithLabelAbove();
// A short label never needs the extra line.
DMD.Options.AddText("Seed", () => _seedText, v => _seedText = v)
.WithLabelAbove(false);
In a shared row, one member asking for it - or a wide member too narrow for its label - moves the labels of its whole line above, so they stay aligned. Buttons have no separate label and ignore it, and pinned copies ignore it too: the single-column dock keeps labels beside their controls, and its multi-column layout puts every label above.
Icons
WithIcon puts an icon on any option - inside the button
for button options, in front of the title for everything else. Once any
option in view carries an icon, the other titles indent to stay
aligned. The pinned dock shows icons too,
deciding per column: a column with any icon indents every title in it,
a column without one indents nothing. Two sources:
Bundled glyphs
DmdIcon is the bundled Material Icons set - over two
thousand glyphs, named like the icon set's own:
using DebugMD;
DMD.Options.AddButton("Report Bug", CaptureReport)
.WithIcon(DmdIcon.BugReport);
DMD.Options.AddFloat("Move Speed", () => _speed, v => _speed = v)
.WithRange(1f, 20f)
.WithIcon(DmdIcon.Speed);
DMD.Options.AddToggle("Favorites Only", () => _favs, v => _favs = v)
.WithIcon(DmdIcon.Favorite);
Your own images
Pass a path instead to show an image. The image must live under a
Resources folder so it ships in builds; both the full
project path and the Resources-relative form work. Unity ships a
Resources folder whole, so these images ship even in
builds without Debug MD.
// Both point at Assets/Game/Resources/Icons/Coin.png:
DMD.Options.AddToggle("Coin Magnet", () => _magnet, v => _magnet = v)
.WithIcon("Assets/Game/Resources/Icons/Coin.png");
DMD.Options.AddToggle("Coin Magnet", () => _magnet, v => _magnet = v)
.WithIcon("Icons/Coin");
An image renders in the same slot and size as the glyphs and takes precedence when both are set. If the image can't be loaded, Debug MD warns once and falls back to the glyph - or to no icon - so a bad path never breaks the panel:
using DebugMD;
// Glyph fallback if the image is missing from Resources.
DMD.Options.AddButton("Grant Skin", GrantSkin)
.WithIcon(DmdIcon.Star)
.WithIcon("Icons/SkinPack");