Hud
public static class HudNamespace Hotline.Api
The Hotline framework’s modder API. Reference Hotline.Api.dll OR drop this single file into your mod. Register a panel and you instantly get a ready-made, toggleable, draggable in-game window inside the one unified Hotline overlay - no custom hotkey, no custom uGUI, no per-mod debug window. One master key opens the overlay; every mod’s controls live there as buttons. Optionally bind a central hotkey to an action and Hotline owns the polling and conflict detection for you.
Every call is a zero-overhead no-op when Hotline is not installed and lights up automatically when it is, so you can ship this unconditionally with no hard dependency.
using Hotline.Api;Hud.RegisterPanel("MyMod", "My Mod") .Text(() => "queue = " + _queue.Count) .Action("Reload", Reload) .Toggle("Verbose", () => _verbose, v => _verbose = v) .Hotkey("Reload", HotlineKey.F8, Reload); // optional central hotkeyTip: a class named HotlineProbe with a static Register() is auto-discovered and called on bind (see AutoRegister), so your mod’s Core does not have to wire anything.
All calls MUST be made from the Unity main thread.
A panel id is any string you pick, usually the mod name, e.g. “MyMod”. It is also the panel’s log channel and the owner of its hotkeys. Each button, toggle and slider gets the id panelId:label-slug: the label in lower case, with every run of other characters turned into ”-”. “Say hi” in the panel “HotlineExample” becomes HotlineExample:say-hi. The console commands hotline act, hotline toggle and hotline slider take that id. A second control with the same label in the same panel replaces the first.
Example
A slider, and the panel shown from code:
Hud.RegisterPanel("MyMod", "My Mod") .Slider("Spawn radius", 5, 50, () => _radius, v => _radius = v, 1, "m");Hud.ShowPanel("MyMod", true);Properties
Section titled “Properties”Available
Section titled “Available”public static bool Available { get; }True only when the Hotline host is installed AND bound. You rarely need this - the API is a safe no-op when absent.
Methods
Section titled “Methods”RegisterPanel
Section titled “RegisterPanel”public static Panel RegisterPanel(string id, string title = null)Types: Panel
Declare a panel: a named, toggleable, movable window in the Hotline overlay that groups everything this mod exposes (text readouts, action buttons, toggles, a log channel). Returns a fluent builder. Load-order-proof; a no-op (the builder still works) if Hotline is absent.
| Parameter | |
|---|---|
id | Your own panel id, e.g. “MyMod”. Null or empty registers nothing, and the returned builder does nothing either. |
title | The window title, e.g. “My Mod”. Null or empty shows the id. The same id again with a title renames the panel. |
RegisterAction
Section titled “RegisterAction”public static void RegisterAction(string panelId, string label, Action run)A clickable button in a mod’s panel - the in-game replacement for a debug hotkey action. Runs on the main thread when clicked. Load-order-proof.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. An unknown id creates a panel titled with that id; null or empty uses the panel “misc”. |
label | The button text, e.g. “Reload”. It also forms the action id, e.g. MyMod:reload. Null or empty registers nothing. |
run | Runs on each click or hotline act call. An exception is caught and logged as a warning. Null registers nothing. |
RegisterToggle
Section titled “RegisterToggle”public static void RegisterToggle( string panelId, string label, Func<bool> get, Action<bool> set)An on/off control in a mod’s panel - the in-game replacement for a toggle hotkey. get reports the current state, set applies it; both run on the main thread. Load-order-proof.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. |
label | The control text, e.g. “Verbose”. It also forms the toggle id, e.g. MyMod:verbose. Null or empty registers nothing. |
get | Returns the current state, e.g. () => _verbose. Null registers nothing. |
set | Applies the new state, e.g. v => _verbose = v. Null registers nothing. |
RegisterSlider
Section titled “RegisterSlider”public static void RegisterSlider( string panelId, string label, double min, double max, Func<double> get, Action<double> set, double step = 0d, string unit = null)A draggable value in a mod’s panel - the in-game replacement for typing a number into a console to find it. get reports the current value, set applies it; both run on the main thread. The host clamps to [min, max] and snaps to step (0 = continuous), so a setter never sees a value outside its range. Load-order-proof; a no-op on an older Hotline host that predates slider support.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. |
label | The text before the value, e.g. “Spawn radius”. It also forms the slider id, e.g. MyMod:spawn-radius. Null or empty registers nothing. |
min | The lowest value, e.g. 5. |
max | The highest value, e.g. 50. A value that is not above min registers nothing. |
get | Returns the current value. Null registers nothing. |
set | Applies a value that is already clamped and snapped. Null registers nothing. |
step | The snap size, e.g. 0.05. 0 or less is continuous. It also sets the decimals shown: up to 2 for 0 or a step of 1 and more, 1 from 0.1, 2 from 0.01, 3 below that. |
unit | Text shown after the value, e.g. “m” or ”%”. Null or empty shows none. |
RegisterText
Section titled “RegisterText”public static void RegisterText(string panelId, Func<string> provider)A free-text, multi-line readout in a mod’s panel. Polled by the host on the main thread. Load-order-proof.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. |
provider | Returns the text, e.g. () => "queue = " + _queue.Count. Each call adds one more readout. Null registers nothing. |
RegisterImage
Section titled “RegisterImage”public static void RegisterImage(string panelId, Func<int[]> provider)An image in a mod’s panel (e.g. a QR code). The provider returns { width, height, argb0, argb1, ... } - ARGB32 pixels, row-major top-down - or null/empty for “nothing to show”. Polled by the host on the main thread and drawn Point-filtered. Kept as a raw int[] so this shim needs no Unity reference. Load-order-proof; a no-op on an older Hotline host that predates image support.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. |
provider | Returns { width, height, pixel0, pixel1, ... } with width times height pixels after the two sizes. Each pixel is 0xAARRGGBB, so opaque black is unchecked((int)0xFF000000). A shorter array, or a width or height of 0 or less, shows nothing. Null registers nothing. |
Example
A 2 x 2 checkerboard:
int b = unchecked((int)0xFF000000), w = unchecked((int)0xFFFFFFFF);Hud.RegisterImage("MyMod", () => new[] { 2, 2, b, w, w, b });BindPanelLog
Section titled “BindPanelLog”public static void BindPanelLog(string panelId)Mark that a panel should display its own log channel (the lines you send via Log / Panel.Write with the same id). Load-order-proof.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. The panel shows the log channel of the same name. |
public static void Log( string channel, string message, LogLevel level = LogLevel.Info)Types: LogLevel
Send a log line to a channel (use your mod/panel id as the channel). It appears in that mod’s panel log AND in Hotline’s combined timeline. Load-order-proof; a no-op if Hotline is absent.
| Parameter | |
|---|---|
channel | Your panel id, e.g. “MyMod”. Null or empty goes to the channel “misc”. A channel keeps its last 400 lines, the combined timeline its last 1200. |
message | The line to show. Null or empty sends nothing. |
level | Info, Warning or Error. The default is Info. |
RegisterHotkey
Section titled “RegisterHotkey”public static void RegisterHotkey( string ownerId, string label, HotlineKey key, Action run)Types: HotlineKey
Bind a central hotkey to an action. Hotline owns the key polling and conflict detection, so every mod’s hotkeys live in one place. Pass HotlineKey.None to skip the key and only label the action. The same action typically also appears as a panel button. Load-order-proof.
| Parameter | |
|---|---|
ownerId | Your panel id, e.g. “MyMod”. Null or empty uses “misc”. |
label | Names the binding, e.g. “Reload”. The same owner and label again replaces the binding. Null or empty registers nothing. |
key | One of F1 to F12, or HotlineKey.None. When two owners bind the same key, both fire and Hotline logs a warning. F6 is Hotline’s default master key. |
run | Runs when the key goes down. An exception is caught and logged as a warning. Null registers nothing. |
ShowOverlay
Section titled “ShowOverlay”public static void ShowOverlay(bool show)Added in 1.3.0
Raise or dismiss the whole overlay from code - the same thing the master key does. Lets a mod offer a console command for its HUD instead of relying on a keypress, which nothing can automate or verify. No-op when Hotline is absent or has not bound yet (this one is NOT queued: showing an overlay minutes later, once the host finally turns up, would be a surprise rather than a favour).
| Parameter | |
|---|---|
show | true raises the overlay, false hides it. |
ShowPanel
Section titled “ShowPanel”public static void ShowPanel(string panelId, bool show)Added in 1.3.0
Show or hide one panel by id. Showing it raises the overlay too, so a single call is enough to put a mod’s panel in front of the player. No-op when Hotline is absent.
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel, e.g. “MyMod”. Null or empty does nothing. |
show | true shows the panel and raises the overlay, false hides the panel. |
IsPanelVisible
Section titled “IsPanelVisible”public static bool IsPanelVisible(string panelId)Added in 1.3.0
Whether a panel is on screen right now (false when Hotline is absent, or the overlay is down).
| Parameter | |
|---|---|
panelId | The id passed to RegisterPanel. Null or empty returns false. |
AutoRegister
Section titled “AutoRegister”public static void AutoRegister()Discover a convention type named HotlineProbe with a static Register() in THIS mod’s own assembly and invoke it once - so a mod never has to wire a Register() call into its Core. Drive it from a [ModuleInitializer] in your probe file. No-op + load-order-proof.