Editor Windows editor only

A tool window can live in your project's scripts rather than in the editor's source. It builds into GameScripts.dll with the rest of your scripts, appears under the editor's Window menu, docks and remembers whether it was open, and comes back on F6 without restarting the editor.

The whole surface is editor/src/api/EditorAPI.h. Everything below is in that header, with longer explanations of the traps; the EditorAPI reference lists every call in one place.

The shortest possible window

Content Browser ▸ right-click ▸ Code ▸ New Editor Window (.cpp) writes a working starter into your project's assets/scripts/. Press F6, and it is in the Window menu — and under Tools, through the menu entry the starter registers. If you would rather type it yourself:

#include "api/EditorAPI.h"
#include "ui/IconsFontAwesome5.h"

using namespace Thread::EditorAPI;

namespace {

    void DrawMyTool() {
        UI::Text("Hello from GameScripts.dll");
        if (UI::Button("Click me"))
            UI::Notify(UI::Level::Success, "Clicked", "It works.");
    }

    EditorWindowRegisterer s_MyTool{ EditorWindowDesc{
        .Id    = "mygame.mytool",
        .Title = "My Tool",
        .Icon  = ICON_FA_WRENCH,
        .Draw  = &DrawMyTool,
    } };

}

Docs/samples/ExampleEditorWindow.cpp is a longer one that exercises every widget and reads the current selection.

A tool window is a lone .cpp with no header, and that is why it still shows in the Content Browser: a gameplay script is a .h, and a .cpp is folded out of the listing only when a header of the same name sits beside it. See Native Scripting.

Why there is no ImGui:: in any of this

editor/CMakeLists.txt hands the script module ImGui's include paths and never the library, deliberately. A module that linked ImGui would get its own copy of ImGui's context pointer and its own allocator, and would then draw into a UI nobody presents while corrupting the one that is — with no link error, no log line, and a stack that points nowhere near the cause.

So a script describes what it wants drawn and the editor draws it. The trade is real: only what EditorAPI.h declares exists, and there is no escape hatch. In exchange, the only way a mismatched module can fail is a missing export — a loud error when the DLL links, or a named entry point when it loads.

The same reasoning explains a few functions that look redundant:

Do not call from a scriptCall insteadWhat happens otherwise
Thread::ScopedEditEditorAPI::Edit EditHistory::Get() reads an inline static, so the module gets a private null. The scene changes and cannot be undone. Nothing is logged.
Thread::ImGuiNotify::*UI::Notify The notifier keeps its queue in an inline static too — the toast is queued into a list nobody draws.
Entity::GetComponent<TagComponent>()EntityName / SetEntityName Works, but only while your module agrees with the editor about entt's component type ids. Going through the export removes the assumption.
The pattern to remember: anything whose state lives in a header-declared static is per-module on Windows. Reaching it from a script is not an error, it just quietly does nothing.

The description

struct EditorWindowDesc {
    std::string Id;                  // stable, lowercase, prefixed with your module's name
    std::string Title;               // shown, WITHOUT the icon
    std::string Icon;                // an ICON_FA_* macro, or empty
    std::string Menu = "Window";     // empty = no menu entry
    Dock        DefaultDock = Dock::Floating;
    bool        DefaultOpen = false;
    int         Order = 0;
    float       DefaultWidth  = 0.0f;
    float       DefaultHeight = 0.0f;
    std::function<void()> Draw;
};

Id is the identity. It keys the saved layout, and nothing refers to a window by title — so renaming the title must not reset anyone's docking. Prefix it (mygame.stats, not stats); a duplicate id is refused with a log line, and the editor's own panels are already using the short names.

Order groups the Window menu: it draws a separator wherever the number changes. The editor's own tools use 0 (authoring) and 10 (diagnostics), so 20 or more puts your module's windows in a block of their own below both.

DefaultOpen is only ever the first answer. A window whose id is in the saved layout comes up as the user left it, and one re-registered by a hot reload comes back exactly as it was a moment ago — so iterating on a tool does not close it on every build.

Drawing

Text, layout and input are the obvious half; read EditorAPI.h for the full list. Two things are worth calling out.

Containers take their contents as a callback. A Begin with no matching End corrupts the whole frame rather than the one widget, and an early return in the middle of a body is the easiest way in the world to write one. So:

UI::Section("Stats", [&]() {
    UI::Table("rows", { "Name", "Count" }, [&]() {
        for (auto& row : rows) {
            UI::TableRow();
            if (UI::TableColumn()) UI::Text(row.Name);
            if (UI::TableColumn()) UI::Text(std::to_string(row.Count));
        }
    });
});

The pairing is structural. It cannot be got wrong, and an exception thrown out of a body still leaves ImGui balanced.

Widgets are identified by their label. The same label twice in one window is one widget as far as input is concerned — which is the "only the first row responds" bug when drawing a list. Wrap each iteration:

for (size_t i = 0; i < items.size(); ++i)
    UI::WithId((int)i, [&]() { if (UI::Button("Remove")) Remove(i); });

Images, plots and a canvas

Textures are named by project path, the way the inspector stores them. They load in the background, and until one arrives a placeholder of the same size holds its place, so the layout does not jump:

UI::Image("assets/textures/rock.png", 128, 0);      // 0 = keep the aspect
if (UI::ImageButton("pick", iconPath, 32, 32)) Pick();
UI::ProgressBar(done / (float)total);
UI::PlotLines("Frame ms", history, 80);             // min/max 0/0 = fit

For anything the widgets do not cover — a curve editor, a node graph, a minimap — reserve a canvas and draw into it. Inside the body, (0,0) is the canvas's top left corner, everything is clipped to it, and the body is told where the mouse is in the same coordinates:

UI::Canvas("curve", 0, 200, [&](const UI::CanvasInput& in) {
    UI::Draw::RectFilled(0, 0, in.Width, in.Height, { 0.10f, 0.11f, 0.13f });
    UI::Draw::Polyline(points, { 0.3f, 0.6f, 1.0f }, false, 2.0f);
    if (in.Hovered) UI::Draw::CircleFilled(in.MouseX, in.MouseY, 4, { 1, 0.6f, 0 });
    if (in.Down[0]) AddPoint(in.MouseX, in.MouseY);
});

Draw:: has lines, rectangles, circles, triangles, polylines, cubic béziers, text and images. Called outside a canvas body it draws nothing and logs one warning. CanvasInput carries the size, the mouse position and this frame's drag, the wheel, and per-button clicked / down / released for left, right and middle.

Drag and drop, and reference fields

Both directions speak the payloads the editor already uses, so your widgets talk to the Content Browser, the Scene Hierarchy, the inspector and the viewport with no glue. Each call acts on the item drawn just before it, like Tooltip:

UI::Image(slotTexture, 64, 64);
if (auto p = UI::AssetDropTarget(Thread::AssetType::Texture); !p.empty()) slotTexture = p;
UI::AssetDragSource(slotTexture);            // drag it onto an inspector field

UI::Text(EntityName(target));
if (auto e = UI::EntityDropTarget()) target = e;   // a row from the hierarchy

Or take the inspector's own rows whole — a drop target, a picker listing every asset of the type (with thumbnails for textures), a clear button; the entity row adds a searchable list of the scene and a button that selects what it points at:

UI::AssetField("Albedo", albedoPath, Thread::AssetType::Texture);
UI::EntityField("Follow", followTarget);

Components, by name

entity.GetComponent<T>() from a module asks entt for T by a type id the module computed, which nothing guarantees is the one the editor's registry was filled with. So components are reached by name, through the same registry the scene serializer and the inspector's Add Component menu use, and their values travel as YAML — exactly the text the component has in a .thread file:

for (auto& name : ComponentsOf(e)) UI::BulletText(name);

if (!HasComponent(e, "PointLightComponent")) { Edit u; AddComponent(e, "PointLightComponent"); }
std::string i = GetComponentField(e, "PointLightComponent", "Intensity");    // "2"
{ Edit u; SetComponentField(e, "PointLightComponent", "Intensity", "5"); }   // one key, rest kept
{ Edit u; PatchComponent(e, "PointLightComponent", "Intensity: 5\nRadius: 12"); }

Thread::Vec3 t, r, s;                       // the transform has its own pair
if (GetTransform(e, t, r, s)) { Edit u; t.y += 1.0f; SetTransform(e, t, r, s); }

A field you can read in a scene file is a field you can read and write here. Rotation is in radians, as the component stores it. ComponentNames() lists everything the registry knows; components that need asset loading (mesh, material, terrain) are serialized apart and are not in it.

Menu items

An entry in the title-bar menus is a path. A menu or submenu the path names is created on demand; a menu that exists only because of your paths lands after Project and before Help, and "File/…" or "Project/…" append to the editor's own:

static MenuItemRegisterer s_Open{ MenuItemDesc{
    .Id     = "mymodule.open",
    .Path   = "Tools/My Module/Open Tool",
    .Icon   = ICON_FA_WRENCH,
    .Action = [] { FocusWindow("mymodule.tool"); },
} };

IsChecked and IsEnabled are optional. The action runs after the menu has closed, so it may open windows or register entries. Same lifetime rules as a window: static, and swept before the module unloads.

Talking to the editor

Thread::Scene*              ActiveScene();
std::string                 ScenePath();        // "" while never saved
bool                        IsPlaying();
std::vector<Thread::Entity> Selection();
Thread::Entity              PrimarySelection();
void                        Select(Thread::Entity);
void                        ClearSelection();
std::string                 EntityName(Thread::Entity);
void                        SetEntityName(Thread::Entity, const std::string&);
Thread::Entity              CreateEntity(const std::string& name = "Entity");
void                        DestroyEntity(Thread::Entity);

ActiveScene() gives you the ECS: scene->GetRegistry().view<TransformComponent>() is inline in the header, so it works from a module. Most of Scene's other methods are defined out of line and are not exported — calling one is an unresolved external when your DLL links, which is the point of the boundary rather than a bug in it. CreateEntity and DestroyEntity are here because those two are worth having and the editor can do them on your behalf.

Scene::FindByUUID(id) is the one out-of-line method that is exported, because a reference to an entity is stored as its id everywhere in this engine — cutscenes, behaviour-tree blackboards, and script entity fields all keep one. It is an indexed lookup, so it is fine to call per frame.

ActiveScene() can be null and the selection can be empty on any frame, including the ones between one scene closing and the next opening. A window draws on all of them. This is not defensive padding; the branch runs.

Bracket every change to the scene so it becomes one undo step, and put the scope around the change, not around the typing — the history snapshots the whole scene per commit, so committing per keystroke fills the undo stack with a hundred versions of one rename:

if (UI::Button("Rename")) {
    Edit undoStep;
    SetEntityName(entity, newName);
}

Lifetime

EditorWindowRegisterer must have static lifetime. Its destructor withdraws the window as FreeLibrary tears the module down, the same way a gameplay script's registration withdraws itself.

The editor also sweeps every script-registered window immediately before unloading a module, so a window registered by hand and never withdrawn still cannot outlive the code that draws it — a Draw is a std::function whose target is code inside the DLL, and one left behind turns the next frame into a call into unmapped memory.

An exception thrown out of your Draw costs that window's contents and nothing else: it is caught, logged, and printed in the window.

Where the files live

Your scripts are the ones in <project>/assets/scripts/. The editor copies them into editor/src/scripts/ before each build — that folder is ephemeral staging, it is wiped on every sync, and nothing you want to keep belongs there. (The one file that survives the wipe is _ScriptRegistrations.cpp, which the editor generates and rewrites itself.)

GameScripts.dll links against ThreadEditor.exe's import library, which is what makes Logger, Input, the script registry, Scene::FindByUUID and this API resolve to the one copy already running in the process rather than to private duplicates.

What this API cannot do yet

Toolbar buttons, viewport overlays and gizmos, custom component inspectors, asset thumbnails, and payload types of your own. Each is a widening of EditorAPI.h, not a redesign — the boundary above is the part that had to be right first.

See also

EditorAPI reference · Scripts & IDE Workflow · Native Scripting · ScriptFields

Okna edytora tylko edytor

Okno narzędziowe może żyć w skryptach projektu zamiast w źródłach edytora. Kompiluje się do GameScripts.dll razem z resztą skryptów, pojawia się w menu Window edytora, dokuje się i pamięta, czy było otwarte, a po F6 wraca bez restartu edytora.

Cała powierzchnia to editor/src/api/EditorAPI.h. Wszystko poniżej jest w tym nagłówku, z dłuższym opisem pułapek; referencja EditorAPI zbiera każde wywołanie w jednym miejscu.

Najkrótsze możliwe okno

Content Browser ▸ prawy klik ▸ Code ▸ New Editor Window (.cpp) zapisuje działający szablon do assets/scripts/ projektu. Naciśnij F6 i jest w menu Window — oraz w Tools, przez pozycję menu, którą szablon rejestruje. Jeśli wolisz napisać to sam:

#include "api/EditorAPI.h"
#include "ui/IconsFontAwesome5.h"

using namespace Thread::EditorAPI;

namespace {

    void DrawMyTool() {
        UI::Text("Hello from GameScripts.dll");
        if (UI::Button("Click me"))
            UI::Notify(UI::Level::Success, "Clicked", "It works.");
    }

    EditorWindowRegisterer s_MyTool{ EditorWindowDesc{
        .Id    = "mygame.mytool",
        .Title = "My Tool",
        .Icon  = ICON_FA_WRENCH,
        .Draw  = &DrawMyTool,
    } };

}

Docs/samples/ExampleEditorWindow.cpp to dłuższy przykład, który używa każdego widgetu i czyta bieżące zaznaczenie.

Okno narzędziowe to samotny .cpp bez nagłówka i dlatego widać je w Content Browserze: skrypt gry to .h, a .cpp jest ukrywany tylko wtedy, gdy obok leży nagłówek o tej samej nazwie. Zob. Skrypty natywne.

Dlaczego nigdzie nie ma ImGui::

editor/CMakeLists.txt daje modułowi skryptów ścieżki nagłówków ImGui, ale nigdy bibliotekę — celowo. Moduł, który zlinkowałby ImGui, dostałby własną kopię wskaźnika kontekstu ImGui i własny alokator, a potem rysowałby w UI, którego nikt nie wyświetla, psując to, które jest wyświetlane — bez błędu linkera, bez linii w logu i ze stosem wskazującym daleko od przyczyny.

Dlatego skrypt opisuje, co chce narysować, a rysuje edytor. Koszt jest prawdziwy: istnieje tylko to, co deklaruje EditorAPI.h, i nie ma tylnych drzwi. W zamian jedyny sposób, w jaki niedopasowany moduł może zawieść, to brakujący eksport — głośny błąd przy linkowaniu DLL albo nazwany punkt wejścia przy wczytywaniu.

To samo rozumowanie tłumaczy kilka funkcji, które wyglądają na zbędne:

Nie wołaj ze skryptuWołaj zamiast tegoCo się stanie w przeciwnym razie
Thread::ScopedEditEditorAPI::Edit EditHistory::Get() czyta inline static, więc moduł dostaje prywatny null. Scena się zmienia i nie da się tego cofnąć. Nic nie trafia do logu.
Thread::ImGuiNotify::*UI::Notify Powiadomienia też trzymają kolejkę w inline static — toast trafia na listę, której nikt nie rysuje.
Entity::GetComponent<TagComponent>()EntityName / SetEntityName Działa, ale tylko dopóki twój moduł zgadza się z edytorem co do id typów komponentów entt. Przejście przez eksport usuwa to założenie.
Wzorzec do zapamiętania: wszystko, czego stan żyje w static zadeklarowanym w nagłówku, na Windows jest osobne dla każdego modułu. Sięgnięcie po to ze skryptu nie jest błędem — po prostu po cichu nic nie robi.

Opis okna

struct EditorWindowDesc {
    std::string Id;                  // stałe, małymi literami, z prefiksem modułu
    std::string Title;               // wyświetlany, BEZ ikony
    std::string Icon;                // makro ICON_FA_* albo pusty
    std::string Menu = "Window";     // pusty = bez pozycji w menu
    Dock        DefaultDock = Dock::Floating;
    bool        DefaultOpen = false;
    int         Order = 0;
    float       DefaultWidth  = 0.0f;
    float       DefaultHeight = 0.0f;
    std::function<void()> Draw;
};

Id to tożsamość. Jest kluczem zapisanego układu, a nic nie odwołuje się do okna po tytule — więc zmiana tytułu nie może nikomu zresetować dokowania. Dodawaj prefiks (mygame.stats, nie stats); duplikat id jest odrzucany z linią w logu, a krótkie nazwy zajmują już panele edytora.

Order grupuje menu Window: separator pojawia się wszędzie, gdzie liczba się zmienia. Narzędzia edytora używają 0 (tworzenie) i 10 (diagnostyka), więc 20 lub więcej daje oknom twojego modułu własny blok pod oboma.

DefaultOpen to tylko pierwsza odpowiedź. Okno, którego id jest w zapisanym układzie, otwiera się tak, jak użytkownik je zostawił, a okno zarejestrowane ponownie przez hot reload wraca dokładnie takie, jakie było chwilę wcześniej — więc praca nad narzędziem nie zamyka go przy każdym buildzie.

Rysowanie

Tekst, układ i pola wejściowe to oczywista połowa; pełna lista jest w EditorAPI.h i w referencji. Dwie rzeczy warto podkreślić.

Kontenery przyjmują zawartość jako callback. Begin bez pasującego End psuje całą klatkę, a nie jeden widget, a wczesny return w środku ciała to najprostszy sposób, żeby taki napisać. Dlatego:

UI::Section("Stats", [&]() {
    UI::Table("rows", { "Name", "Count" }, [&]() {
        for (auto& row : rows) {
            UI::TableRow();
            if (UI::TableColumn()) UI::Text(row.Name);
            if (UI::TableColumn()) UI::Text(std::to_string(row.Count));
        }
    });
});

Parowanie wynika ze struktury. Nie da się go pomylić, a wyjątek rzucony z ciała nadal zostawia ImGui w równowadze.

Widgety są rozpoznawane po etykiecie. Ta sama etykieta dwa razy w jednym oknie to dla wejścia jeden widget — to błąd „reaguje tylko pierwszy wiersz” przy rysowaniu listy. Owiń każdą iterację:

for (size_t i = 0; i < items.size(); ++i)
    UI::WithId((int)i, [&]() { if (UI::Button("Remove")) Remove(i); });

Obrazki, wykresy i canvas

Tekstury wskazujesz ścieżką projektu, tak jak zapisuje je inspektor. Wczytują się w tle, a dopóki nie dotrą, ich miejsce zajmuje prostokąt tego samego rozmiaru, więc układ nie skacze:

UI::Image("assets/textures/rock.png", 128, 0);      // 0 = zachowaj proporcje
if (UI::ImageButton("pick", iconPath, 32, 32)) Pick();
UI::ProgressBar(done / (float)total);
UI::PlotLines("Frame ms", history, 80);             // min/max 0/0 = dopasuj

Do wszystkiego, czego nie pokrywają widgety — edytor krzywych, graf węzłów, minimapa — zarezerwuj canvas i rysuj w nim. W ciele (0,0) to lewy górny róg canvasu, wszystko jest do niego przycinane, a ciało dostaje pozycję myszy w tych samych współrzędnych:

UI::Canvas("curve", 0, 200, [&](const UI::CanvasInput& in) {
    UI::Draw::RectFilled(0, 0, in.Width, in.Height, { 0.10f, 0.11f, 0.13f });
    UI::Draw::Polyline(points, { 0.3f, 0.6f, 1.0f }, false, 2.0f);
    if (in.Hovered) UI::Draw::CircleFilled(in.MouseX, in.MouseY, 4, { 1, 0.6f, 0 });
    if (in.Down[0]) AddPoint(in.MouseX, in.MouseY);
});

Draw:: ma linie, prostokąty, okręgi, trójkąty, łamane, krzywe Béziera, tekst i obrazki. Wywołane poza ciałem canvasu niczego nie rysuje i raz zapisuje ostrzeżenie. CanvasInput niesie rozmiar, pozycję myszy i przesunięcie w tej klatce, kółko oraz kliknięcia / przytrzymania / puszczenia lewego, prawego i środkowego przycisku.

Drag & drop i pola referencji

Oba kierunki mówią formatami, których edytor już używa, więc twoje widgety rozmawiają z Content Browserem, Scene Hierarchy, inspektorem i viewportem bez kleju. Każde wywołanie działa na element narysowany tuż przed nim, jak Tooltip:

UI::Image(slotTexture, 64, 64);
if (auto p = UI::AssetDropTarget(Thread::AssetType::Texture); !p.empty()) slotTexture = p;
UI::AssetDragSource(slotTexture);            // przeciągnij na pole w inspektorze

UI::Text(EntityName(target));
if (auto e = UI::EntityDropTarget()) target = e;   // wiersz z hierarchii

Albo weź całe wiersze inspektora — cel upuszczania, wybór listujący każdy asset danego typu (z miniaturami tekstur), przycisk czyszczenia; wiersz encji dodaje listę sceny z wyszukiwarką i przycisk, który zaznacza wskazywaną encję:

UI::AssetField("Albedo", albedoPath, Thread::AssetType::Texture);
UI::EntityField("Follow", followTarget);

Komponenty po nazwie

entity.GetComponent<T>() z modułu pyta entt o T po id typu policzonym przez moduł, a nic nie gwarantuje, że to ten sam, którym wypełniono rejestr edytora. Dlatego do komponentów sięga się po nazwie, przez ten sam rejestr, którego używają serializer sceny i menu Add Component inspektora, a wartości podróżują jako YAML — dokładnie ten tekst, który komponent ma w pliku .thread:

for (auto& name : ComponentsOf(e)) UI::BulletText(name);

if (!HasComponent(e, "PointLightComponent")) { Edit u; AddComponent(e, "PointLightComponent"); }
std::string i = GetComponentField(e, "PointLightComponent", "Intensity");    // "2"
{ Edit u; SetComponentField(e, "PointLightComponent", "Intensity", "5"); }   // jeden klucz, reszta bez zmian
{ Edit u; PatchComponent(e, "PointLightComponent", "Intensity: 5\nRadius: 12"); }

Thread::Vec3 t, r, s;                       // transform ma własną parę
if (GetTransform(e, t, r, s)) { Edit u; t.y += 1.0f; SetTransform(e, t, r, s); }

Pole, które przeczytasz w pliku sceny, możesz tu przeczytać i zapisać. Rotacja jest w radianach, tak jak przechowuje ją komponent. ComponentNames() wymienia wszystko, co zna rejestr; komponenty wymagające wczytywania assetów (siatka, materiał, teren) są serializowane osobno i ich tam nie ma.

Pozycje menu

Pozycja w menu paska tytułu to ścieżka. Menu i podmenu wskazane ścieżką powstają same; menu, które istnieje tylko dzięki twoim ścieżkom, ląduje po Project i przed Help, a "File/…" czy "Project/…" dopisują się do menu edytora:

static MenuItemRegisterer s_Open{ MenuItemDesc{
    .Id     = "mymodule.open",
    .Path   = "Tools/My Module/Open Tool",
    .Icon   = ICON_FA_WRENCH,
    .Action = [] { FocusWindow("mymodule.tool"); },
} };

IsChecked i IsEnabled są opcjonalne. Akcja wykonuje się po zamknięciu menu, więc może otwierać okna albo rejestrować pozycje. Zasady życia jak dla okna: statyczny obiekt, sprzątany przed wyładowaniem modułu.

Rozmowa z edytorem

Thread::Scene*              ActiveScene();
std::string                 ScenePath();        // "" dopóki nie zapisano
bool                        IsPlaying();
std::vector<Thread::Entity> Selection();
Thread::Entity              PrimarySelection();
void                        Select(Thread::Entity);
void                        ClearSelection();
std::string                 EntityName(Thread::Entity);
void                        SetEntityName(Thread::Entity, const std::string&);
Thread::Entity              CreateEntity(const std::string& name = "Entity");
void                        DestroyEntity(Thread::Entity);

ActiveScene() daje dostęp do ECS: scene->GetRegistry().view<TransformComponent>() jest w nagłówku, więc działa z modułu. Większość innych metod Scene jest zdefiniowana poza nagłówkiem i nieeksportowana — ich wywołanie to nierozwiązany symbol przy linkowaniu DLL, i to jest sens tej granicy, a nie jej błąd. CreateEntity i DestroyEntity są tu, bo te dwie warto mieć, a edytor może je wykonać za ciebie.

Scene::FindByUUID(id) to jedyna metoda spoza nagłówka, która jest eksportowana, bo odwołanie do encji jest w tym silniku wszędzie zapisywane jako jej id — przerywniki, tablice drzew zachowań i pola skryptów wskazujące encje. To wyszukiwanie po indeksie, więc można je wołać co klatkę.

ActiveScene() może być null, a zaznaczenie puste w każdej klatce, także w tych między zamknięciem jednej sceny a otwarciem następnej. Okno rysuje się we wszystkich. To nie przesadna ostrożność; ta gałąź się wykonuje.

Każdą zmianę sceny owiń, żeby stała się jednym krokiem cofania, i obejmij zmianę, a nie pisanie — historia zapisuje całą scenę przy każdym zatwierdzeniu, więc zatwierdzanie przy każdym klawiszu zapcha stos cofania setką wersji jednej zmiany nazwy:

if (UI::Button("Rename")) {
    Edit undoStep;
    SetEntityName(entity, newName);
}

Czas życia

EditorWindowRegisterer musi mieć statyczny czas życia. Jego destruktor wycofuje okno, gdy FreeLibrary rozbiera moduł — tak samo jak rejestracja skryptu gry wycofuje się sama.

Edytor sprząta też wszystkie okna zarejestrowane przez skrypty tuż przed wyładowaniem modułu, więc okno zarejestrowane ręcznie i nigdy niewycofane nadal nie przeżyje kodu, który je rysuje — Draw to std::function, którego cel jest kodem w DLL, a pozostawione okno zamieniłoby następną klatkę w skok do niezmapowanej pamięci.

Wyjątek rzucony z twojego Draw kosztuje zawartość tego okna i nic więcej: jest łapany, logowany i wypisywany w oknie.

Gdzie leżą pliki

Twoje skrypty to te w <projekt>/assets/scripts/. Edytor kopiuje je do editor/src/scripts/ przed każdym buildem — ten folder to ulotna kopia robocza, czyszczona przy każdej synchronizacji, i nie należy tam trzymać niczego, co chcesz zachować. (Jedyny plik, który przetrwa czyszczenie, to _ScriptRegistrations.cpp, który edytor sam generuje i nadpisuje.)

GameScripts.dll linkuje się z biblioteką importu ThreadEditor.exe — dlatego Logger, Input, rejestr skryptów, Scene::FindByUUID i to API trafiają w jedną kopię działającą już w procesie, a nie w prywatne duplikaty.

Czego to API jeszcze nie potrafi

Przyciski na toolbarze, nakładki i gizma w viewporcie, własne inspektory komponentów, miniatury assetów i własne typy payloadu drag & drop. Każde to rozszerzenie EditorAPI.h, a nie przeprojektowanie — granica opisana wyżej to część, która musiała być dobra najpierw.

Zobacz też

Referencja EditorAPI · Skrypty i IDE · Skrypty natywne · ScriptFields