๐งฑ Extension Modules / Addons
Extensions are plug-and-play modules โ an easy way to move a feature between projects or share one with the community. Pick only what your project needs and the console stays lightweight.
๐งฉ The extension points
Everything below is an IConsoleModule. Add IConsoleExtension too and NjConsole creates it for you from
Project Settings instead of you registering it in code.
| Interface | What it lets you add | Docs |
|---|---|---|
IConsolePanelModule |
A whole new panel (UI Toolkit) | Custom Panels |
IConsoleIMGUIPanelModule |
A new panel drawn with OnGUI / IMGUI | Custom Panels |
IConsoleCommandlineModule |
A custom command executor or an interactive prompt | Command Line |
IConsoleOverlayTrigger |
Your own way to open the runtime overlay | Console Window |
IConsoleAccessChallenge |
A gate before the console opens (e.g. your login) | Console Window |
IConsoleTimestampFormatter |
How timestamps are drawn in the Logs panel | Logging |
IConsoleLogExportFormatter |
Header / footer / line format for exported and emailed logs | Logging |
IConsoleExtension alone |
Anything else โ run setup code when the console starts | below |
Two IConsoleModule members worth knowing:
PersistInEditModeโtrueto survive leaving play mode, needed for anything that works in the editor window outside play mode. Defaults tofalse.OnAdded(ConsoleModules modules)/Dispose()โ setup and teardown.
โ ๏ธ Implement
OnAddedexplicitly (void IConsoleModule.OnAdded(...)) or make itpublic. A privatevoid OnAdded(...)will silently not be called.
๐ฆ External Extensions Repo
You can find some extensions here:
https://github.com/Ninjadini/njconsole/tree/main/extension-modules
Each usually has a README or comments on how to include it.
Early days โ there may not be much there yet.
โจ Create Your Own Extension
- Implement
IConsoleExtension. - Add
[Serializable]โ thatโs what makes its fields editable in Project Settings. - Keep it a plain data class, not a
MonoBehaviourorScriptableObject. - Go to
Project Settings>Ninjadini โจ Console>Extension Modulesand add it. - Press
Apply extension changes.
A simple one that registers an option menu item:
[Serializable]
public class ExampleExtension : IConsoleExtension
{
void IConsoleModule.OnAdded(ConsoleModules modules)
{
var catalog = modules.GetOrCreateModule<ConsoleOptions>().CreateCatalog();
catalog.AddButton("Extensions/Say Hello", () =>
{
Debug.Log("Hello!");
});
}
}
Public serializable fields appear as editable settings next to it, so an extension can ship its own config.
๐ง Registering in code instead
For a module created at runtime, or one that shouldnโt be in every build, add it directly:
if (NjConsole.Modules.GetModule(typeof(MyModule)) == null)
{
NjConsole.Modules.AddModule(new MyModule());
}
Other ConsoleModules APIs: GetOrCreateModule<T>(), GetModule<T>(includeSubClasses),
RemoveModule(type), HasModule(module), and the ModuleAdd / ModuleRemoved events.