Scripted Editor Windows

Scripted Editor Windows let a compiled script expose an ImGui-powered editor tab inside Modularity. You export two C-linkage functions, the engine discovers them, and it will call your render hook eve

Required Exports

In your script, export these functions with C linkage and a ScriptContext& parameter:

  1. RenderEditorWindow(ScriptContext& ctx) Called every frame while the window/tab is open.

  2. ExitRenderEditorWindow(ScriptContext& ctx) Called once when the window/tab is closed.

Example

ScriptedEditorWindow.cpp
#include "ScriptContext.hpp"
#include "imgui.h"

extern "C"
{
    void RenderEditorWindow(ScriptContext& ctx)
    {
        ImGui::Text("Hello from script!");

        if (ImGui::Button("Log"))
            ctx.AddConsoleMessage("Editor window clicked");
    }

    void ExitRenderEditorWindow(ScriptContext& ctx)
    {
        ctx.AddConsoleMessage("Editor window closed");
    }
}

Build + Placement

  1. Build the script normally.

  2. Ensure the compiled binary lands in the location your Scripts.modu config points to (the engine loads binaries from there).


Using It In The Editor

  1. Attach the script to any scene object.

  2. Modularity scans the compiled binary for the exported functions above.

  3. The editor adds a toggle entry at:

View → Scripted Windows

  • The menu label is the binary name (ex: MyTools.dll / MyTools.so).

  • When enabled, Modularity opens a tab and calls RenderEditorWindow(...) every frame.

  • When the tab closes, Modularity calls ExitRenderEditorWindow(...) once.


Notes

  1. Your window UI should be pure ImGui (draw every frame inside RenderEditorWindow).

  2. If you don’t export ExitRenderEditorWindow, closing cleanup won’t run (so keep it, even if empty).

Last updated

Was this helpful?