Option types
Every kind of control the panel offers, and the two ways to register one.
Two registration styles
The default style is a one-liner: the Add* shorthands on
DMD.Options create the option, register it, and return the
typed option so modifiers chain straight on:
DMD.Options.AddToggle("God Mode", () => _god, v => _god = v);
The long form separates creation from registration: build the option
with a static Option factory, then pass it to
Add. Add returns an OptionHandle -
use this form when you need the handle (removal, pinning, refresh
pushes) or the owner-bound overload:
using DebugMD;
var option = Option.Toggle("God Mode", () => _god, v => _god = v);
OptionHandle handle = DMD.Options.Add(option, this); // removed when this object dies
Both forms produce the same option. Handles, owners and scopes are covered in Lifetime & scopes.
At a glance
| Type | Shorthand | Renders as |
|---|---|---|
| Toggle | AddToggle | On/off switch |
| Int | AddInt | Number control; range bar with WithRange |
| Float | AddFloat | Number control; range bar with WithRange |
| Long | AddLong | 64-bit number control; range bar with WithRange |
| Double | AddDouble | Double-precision number control; range bar with WithRange |
| Text | AddText | Editable text field |
| Choice<TEnum> | AddChoice | Current value; opens the searchable picker |
| Button | AddButton | Button invoking an action |
| Info | AddInfo | Read-only text row, polled live |
| Picker<T> | AddPicker | Searchable, virtualized collection picker |
| MultiPicker<T> | AddMultiPicker | Collection picker with any number selected |
Toggle
A boolean switch. The getter is polled while the widget is visible, so the switch tracks state changed elsewhere in code. As in a phone's settings screen, the checkbox sits at the right edge of the row and the label takes the rest of the width, so a stack of toggles lines up in one column on the right:
DMD.Options.AddToggle("Invincible", () => _invincible, v => _invincible = v);
// No setter - renders as a read-only indicator.
DMD.Options.AddToggle("Server Connected", () => Net.IsConnected);
Int and Float
Every number option renders as the same compact control: the value
with a thin arrow either side, < 0.75 >. Declare
WithRange and the value is constrained, with a thin fill bar
just below the value box showing where it sits in the range;
WithStep sets the increment used by the arrows and by range
snapping:
DMD.Options.AddInt("Level", () => _level, v => _level = v)
.WithRange(1, 50);
DMD.Options.AddFloat("Time Scale", () => Time.timeScale, v => Time.timeScale = v)
.WithRange(0f, 3f)
.WithStep(0.25f);
Steps behave per type: an int step is clamped to at least
1; a float step of 0 means continuous - the
range bar doesn't snap. Keep WithRange and
WithStep ahead of placement modifiers in the chain.
There are three ways to change the value:
- Arrows step it down or up by one step. Hold an arrow and it repeats.
- Tap or click the value to type a new one. Enter or leaving the field commits it, Escape cancels, and text that doesn't parse as a number is ignored.
- Drag the value sideways to scrub it. The drag is
direction-locked, so a mostly vertical drag is left to the list's
scrolling. Without a range the value moves by its step every few
pixels (a float or double with no step scrubs in tenths); with a range
the control's width maps onto the whole range. Dragging the range bar
itself works like a slider and snaps to
WithStepwhen one is declared.
A read-only number shows no arrows and can't be typed into or dragged.
Step arrows
The arrows either side of the value nudge it by its step. They are the fastest way to walk a value on a phone, where typing means fighting the on-screen keyboard and dragging to an exact number is a thumb-width of guesswork. They show up wherever the option does, including pinned to the screen, and they respect a read-only option by not appearing at all.
| Option | Steps by |
|---|---|
| Int or Long, any form | Its WithStep, which defaults to 1 |
Float or Double with WithStep | The increment you set |
| Float or Double without a step | 1. A fractional value with no step is continuous, so the range bar snaps to nothing - but the arrows still need a defined amount to add, and one whole unit is what a bare arrow reads as. |
| Read-only (no setter) | No arrows at all |
Pressing an arrow adds or subtracts one step, clamps the result to
WithRange if the option has one, and writes it through your
setter. The value shown afterwards is read back from your getter, not
assumed - if your setter clamps or ignores the write, the panel shows what
your code actually did.
The arrows are on by default and are worth leaving alone. When you do
want to decide per option, WithStepButtons settles it in both
directions:
// Stepping by 1 is meaningless here - drop the arrows.
DMD.Options.AddInt("Random Seed", () => _seed, v => _seed = v)
.WithStepButtons(false);
// Worth nudging even in a project that turned the arrows off.
DMD.Options.AddFloat("Gravity", () => _gravity, v => _gravity = v)
.WithStep(0.5f)
.WithStepButtons();
Without that modifier an option follows the project's Step
Buttons setting (Window › Debug MD › Settings, under
Panel Appearance), which controls the arrows. Turning it off makes them
opt-in, and
WithStepButtons() is how a particular option opts back in.
Like most panel settings it is
overridable per device from the
About page, so a tester on a small phone can have them without a new
build - and the panel re-renders the moment it is toggled.
Wide ranges: curves
A range that spans orders of magnitude - 10 to 10,000 coins, 0.001 to
1 seconds - is hard to set on a straight bar: the small values you care
about get a few pixels, the huge ones get the rest. WithCurve
bends the range so the bar spends its travel where the precision
matters:
DMD.Options.AddInt("Cash", () => _cash, v => _cash = v)
.WithRange(10, 10000)
.WithCurve(); // exponent 3 by default
- The exponent sets the bend. The bar position t (0 to 1) stands for the fraction texponent of the range. 1 is linear; 2 to 3 feels logarithmic - with 3, the first half of a 10-10,000 bar covers 10 to about 1,260. Below 1 bends the other way, giving the precision to the top. Unlike a true log scale it works with a minimum of 0.
- Everything follows it. Dragging the bar, scrubbing sideways and the arrows: one press moves a small step along the curve, so it nudges by 1 near 10 and by 100 near 5,000, always landing on tidy values (two significant digits for arrows, three for dragging) rather than numbers like 1263.7461.
- Exact values stay one tap away. Typing takes any
number, and a declared
WithStepstill snaps the result.
A curve needs a range to bend; without WithRange it has
no effect. It works the same on all four number types, in the panel, the
pinned dock and the editor window.
Long and Double
Two more number types cover what int and
float cannot hold: AddLong for totals, tick
counts and identifiers past two billion, and AddDouble for
values a float would round away, like accumulated simulation time.
DMD.Options.AddLong("Total XP", () => _totalXp, v => _totalXp = v)
.WithStep(1_000_000);
DMD.Options.AddDouble("Sim Time", () => _simTime, v => _simTime = v)
.WithStep(0.001);
They render with the same number control as
their narrower siblings: arrows, typing, sideways scrubbing, and a range
bar once you declare WithRange. Long math stays exact 64-bit
throughout, so stepping or clamping a long past two billion never rounds
it. WithStep and the step arrows
work exactly as they do elsewhere.
Text
An editable string field:
DMD.Options.AddText("Player Name", () => _playerName, v => _playerName = v);
Choice
An enum-backed option. The panel row shows the current value; choosing opens the same searchable full-screen overlay the pickers use, which beats a dropdown once an enum grows past a handful of members:
public enum Difficulty { Easy, Normal, Hard, Nightmare }
DMD.Options.AddChoice("Difficulty", () => _difficulty, v => _difficulty = v);
Omit the setter to display the current value read-only.
Button
Invokes an action when pressed:
using UnityEngine;
DMD.Options.AddButton("Restart Run", RestartRun)
.WithKeyBinding(KeyCode.R);
WithKeyBinding also fires the action when the key is
pressed during play - whether the panel is open or closed. Presses are
ignored while a text field is being edited, and buttons sharing a key
all fire. On platforms without a physical keyboard (mobile, consoles)
the binding is inactive and the button shows no key hint.
Info
A read-only text row polled while visible - the way to surface counters, scene names, build info or anything else worth watching:
using UnityEngine;
using UnityEngine.SceneManagement;
DMD.Options.AddInfo("Scene", () => SceneManager.GetActiveScene().name);
DMD.Options.AddInfo("Frame", () => Time.frameCount.ToString());
The name sits on the left and the value at the right edge, both in full when they fit side by side. When they collide, the name keeps about half the row (more if the value is short) and the value wraps beside it.
Read-only options
Every value option - Toggle, Int, Float, Long, Double, Text, Choice - and both
pickers render read-only when you omit the setter. That is the pattern
for state you want visible but untouchable. On the value options,
IsReadOnly reports which mode the option is in; the pickers
simply become browse-only (or, with AsDisplay(), a
live preview row that does not
open). Info is the shorthand for the
most common case, a read-only string.