Mod Loader/Reference/Debug console API
Appearance
Open the in-game console with Ctrl+`. Type help to list commands. The console keeps the latest 120 output lines in memory; the full session log remains in BepInEx/LogOutput.log.
Register a command
Commands run on Unity's main thread. A handler receives the text after the command name as one string and returns text to print. Command names may contain letters, digits, hyphens, and underscores.
using System;
using BepInEx;
using DressmakerMods;
[BepInPlugin("example.inspect", "Inspect Example", "1.0.0")]
[BepInDependency("yuu.dressmaker.mods", "0.6.74")]
public sealed class InspectExample : BaseUnityPlugin
{
private IDisposable command;
private void Awake()
{
command = DebugConsoleApi.Register("hello", "Greet someone.", name =>
"Hello, " + (name.Length == 0 ? "Dressmaker" : name) + "!");
DebugConsoleApi.Write("Try: hello Yuu");
}
private void OnDestroy() => command?.Dispose();
}
Registering a name that is already in use throws an exception. Dispose the registration when your plugin unloads.
Methods and properties
IDisposable Register(string name, string description, Func<string, string> handler)- Adds a command. The handler argument is the full remainder of the command line.
string Run(string commandLine)- Runs a command as if entered in the console and returns its result. Unknown commands return an error string.
void Write(string message)- Adds text to the console output. Newlines create separate lines.
bool IsOpen- True while the console window is open.
Built-in commands are help, clear, version, and scene. Exceptions thrown by a command handler appear in the console and loader log.