-
-
Notifications
You must be signed in to change notification settings - Fork 8
[EU] Editor Modules
Editor modules are a way to extend the editor with custom tools
There are 4 types of modules
- Details Panel
- Tools
- Independent
- Top Bar
These modules are rendered using function pointers/lambdas containing calls to dear imgui
- Details panel - requires a pointer to an actor as an argument
- Tools - requires a tool flag as an argument
- Independent - requires an info struct as an argument
- Top bar - takes nothing as an argument
Details panel module creation
EditorModules::addDetailsPanelModule([](Actor*, bool&){ ImGui::Text("Hello, World!"); });
Tools module creation
EditorModules::addToolsModule([](const UVK::CurrentToolType&, bool&){ ImGui::Text("Hello, World!"); });
Top bar module creation
EditorModules::addTopBar([](bool&){ ImGui::Text("Hello, World!"); });
Independent module creation
IndependentModuleData data =
{
.bEnabled = true,
.func = [](const char* name, bool& bShow, bool&)
{
ImGui::Begin(name, &bShow);
ImGui::Text("Hello, World!");
ImGui::End();
},
.name = "Testing module"
};
EditorModules::addIndependentModule(data);
You can now create a module, but you need to put that creation code somewhere. There is a designated function for that very purpose in the game instance called onEventInitEditorModules
The details panel's module type takes a pointer to an actor. This pointer can be used to check for components.
The independent module function takes a name and an enabled boolean. The name is responsible for the name of the window, the enabled boolean is for enabling/disabling the window. Independent modules are listed under the view tab in the title bar and can be enabled/disabled from there.
The tools module, takes an enum for the current tools' module type. Due to the fact that the tools' widget contains 3 views
- Terrain editor
- Object
- Custom
the enum can be used to check if the current active view is one of the three
The engine comes with 2 additional dear imgui libraries
- ImGuizmo - a gizmo for imgui
- ImPlot - a library to display statistics using imgui
You can learn those 2 libraries and use them in your widgets to display statistics or to have different types of controls
You might be wondering what the last bool&
argument does. This argument is tied to the Transactions
and Undo/Redo
API. When having input widgets in dear imgui such as ImGui::InputText
, they have their own Undo/Redo
system. Instead of disabling their Undo/Redo
system and implementing our own, we decided to use their Undo/Redo
system and disable ours when interacting with input widgets. This can be done with this bool. Here is a sample of what is recommended:
if (ImGui::InputText(("##Rename" + a.path().string()).c_str(), &renameText) || ImGui::IsItemFocused())
bReturn = true;
This is extracted from Filesystem.cpp
, line 218-219. As you can see, we check if the input function returns true or if the widget is focused. If the check returns true, then we can enable our bool
named bReturn
and disable interactions with the engine's Undo/Redo
API.
This project is supported by all the people who joined our discord server and became beta testers. If you want to join the discord you can click here
- Home
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources