ImGui in Scripts
Modularity uses Dear ImGui for editor UI. Scripts can draw ImGui in two places: the Inspector panel (per object) and custom scripted editor windows.
Inspector UI (Per Object)
Export Script_OnInspector(ScriptContext&) to draw custom UI in the Inspector:
Scripts/InspectorUI.cpp CPP
1
400">class="text-violet-400">#include "ScriptRuntime.h"
2
400">class="text-violet-400">#include "ThirdParty/imgui/imgui.h"
3
4
400">static 400">bool autoRotate = 400">false;
5
6
400">extern "C" 400">void Script_OnInspector(400">ScriptContext& ctx) {
7
400">ImGui::Checkbox("Auto Rotate", &autoRotate);
8
ctx.MarkDirty();
9
}
Tip: Script_OnInspector must be exported exactly with extern "C" (it is not wrapper-generated).
Important: Do not call ImGui functions (e.g., ImGui::Text) from TickUpdate or other runtime hooks. Those run before the ImGui frame is active and outside any window, which can crash.
Scripted Editor Windows
See Scripted Editor Windows for creating custom editor tabs.