UI System
Menus and HUDs are built on the engine's own screen-space UI — not on ImGui (which is the
editor's tooling only). UI entities live in the same scene/ECS and are clickable in the runtime
through the UISystem. Author them in the editor's UI Designer and save them as .ui
assets, or build them from code.
Building blocks
| Component | Role |
|---|---|
| UICanvasComponent | Root of a UI tree; defines the screen-space canvas. |
| UITransformComponent | Anchored rect (position/size/anchor) for a UI element. |
| UIImageComponent | Sprite/panel, with optional 9-slice for scalable frames. |
| UITextComponent | Text label (bitmap font). |
| UIButtonComponent | Clickable button; fires a named action. |
| UISlider / UIToggle / UIDropdown / UIProgressBar | Standard interactive widgets. |
| UILayoutGroupComponent | Auto-arranges children (rows/columns). |
| UIScrollViewComponent | Clipped, scrollable content region. |
| HUDComponent | Marks a canvas as an in-game HUD. |
Named actions UIActions
A button authored in the editor runs game code through a named action. Register a handler in
C++ and reference its name from the widget's ActionName:
Thread::UIActions::Bind("menu.start", [] {
// load the first level, switch state machine to Playing, …
});
Widgets (button / slider / toggle / dropdown) carry a serializable ActionName, so a
menu authored entirely in the editor can drive gameplay. Dispatch is deferred to
the top of the next frame — handlers may rebuild the scene safely. The same mechanism backs
TriggerComponent's OnEnter/OnExit actions.
System UI
Menu i HUD-y powstają na własnym UI silnika w przestrzeni ekranu — nie na ImGui (to wyłącznie
narzędzia edytora). Encje UI żyją w tej samej scenie/ECS i w grze są klikalne przez UISystem.
Tworzysz je w UI Designerze edytora i zapisujesz jako assety .ui albo budujesz z
kodu.
Elementy
| Komponent | Rola |
|---|---|
| UICanvasComponent | Korzeń drzewa UI; określa canvas w przestrzeni ekranu. |
| UITransformComponent | Zakotwiczony prostokąt (pozycja/rozmiar/kotwica) elementu UI. |
| UIImageComponent | Sprite/panel, z opcjonalnym 9-slice dla skalowalnych ramek. |
| UITextComponent | Etykieta tekstowa (czcionka bitmapowa). |
| UIButtonComponent | Klikalny przycisk; wywołuje nazwaną akcję. |
| UISlider / UIToggle / UIDropdown / UIProgressBar | Standardowe interaktywne widgety. |
| UILayoutGroupComponent | Automatycznie układa dzieci (wiersze/kolumny). |
| UIScrollViewComponent | Przycinany, przewijany obszar treści. |
| HUDComponent | Oznacza canvas jako HUD w grze. |
Nazwane akcje UIActions
Przycisk zrobiony w edytorze uruchamia kod gry przez nazwaną akcję. Zarejestruj handler w C++ i
wpisz jego nazwę w ActionName widgetu:
Thread::UIActions::Bind("menu.start", [] {
// wczytaj pierwszy poziom, przełącz maszynę stanów na Playing, …
});
Widgety (przycisk / suwak / przełącznik / lista) mają zapisywane ActionName, więc menu
zrobione w całości w edytorze może sterować rozgrywką. Wywołanie jest odroczone na
początek następnej klatki — handlery mogą bezpiecznie przebudować scenę. Ten sam mechanizm obsługuje
akcje OnEnter/OnExit TriggerComponent.