Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(ui): CSS display:none — one hierarchical show/hide across layout, render, text and input

esengine18d9ba205ee1
diff --git a/sdk/src/component.generated.ts b/sdk/src/component.generated.ts
index 8e30bdfd2..35646343c 100644
--- a/sdk/src/component.generated.ts
+++ b/sdk/src/component.generated.ts
@@ -15,7 +15,7 @@ import type { Dimension, Padding } from './wasm.generated';
* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to
* run on mismatch, because mismatched offsets read the wrong heap bytes.
*/
-export const ABI_LAYOUT_HASH = 'f9191aeae848066e';
+export const ABI_LAYOUT_HASH = 'bde213b560e9ce4c';
export interface AssetFieldMeta {
field: string;
@@ -622,6 +622,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
UINode: {
defaults: {
position: 0,
+ display: 0,
width: { value: 0, unit: 2 },
height: { value: 0, unit: 2 },
minWidth: { value: 0, unit: 2 },
@@ -647,6 +648,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
animatableFields: [],
fields: {
position: { enum: [{ label: 'Relative', value: 0 }, { label: 'Absolute', value: 1 }] },
+ display: { enum: [{ label: 'Flex', value: 0 }, { label: 'None', value: 1 }], tooltip: "None removes this node and its whole subtree from layout, rendering and input." },
alignSelf: { enum: [{ label: 'Auto', value: 0 }, { label: 'Start', value: 1 }, { label: 'Center', value: 2 }, { label: 'End', value: 3 }, { label: 'Stretch', value: 4 }] },
},
},
@@ -977,6 +979,7 @@ export interface UIMaskData {
export interface UINodeData {
position: number;
+ display: number;
width: Dimension;
height: Dimension;
minWidth: Dimension;
diff --git a/sdk/src/core-ui.ts b/sdk/src/core-ui.ts
index 75580f9c5..76e1976d0 100644
--- a/sdk/src/core-ui.ts
+++ b/sdk/src/core-ui.ts
@@ -144,6 +144,7 @@ export {
type Dimension,
// UINode layout enums
UIPositionType,
+ UIDisplay,
AlignSelf,
// Flex container
FlexContainer,
diff --git a/sdk/src/ecs/ptrAccessors.generated.ts b/sdk/src/ecs/ptrAccessors.generated.ts
index 12ff9dbf4..5f9bd5eb2 100644
--- a/sdk/src/ecs/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/ptrAccessors.generated.ts
@@ -1263,6 +1263,7 @@ export function createUIMaskData(): UIMaskPtrData {
export interface UINodePtrData {
position: number;
+ display: number;
flexGrow: number;
flexShrink: number;
alignSelf: number;
@@ -1273,6 +1274,7 @@ export function fillUINode(
ptr: number, out: UINodePtrData,
): void {
out.position = u8[ptr];
+ out.display = u8[ptr + 1];
out.flexGrow = f32[(ptr + 52) >> 2];
out.flexShrink = f32[(ptr + 56) >> 2];
out.alignSelf = u8[ptr + 68];
@@ -1283,6 +1285,7 @@ export function writeUINode(
ptr: number, data: UINodePtrData,
): void {
u8[ptr] = data.position;
+ u8[ptr + 1] = data.display;
f32[(ptr + 52) >> 2] = data.flexGrow;
f32[(ptr + 56) >> 2] = data.flexShrink;
u8[ptr + 68] = data.alignSelf;
@@ -1291,6 +1294,7 @@ export function writeUINode(
export function createUINodeData(): UINodePtrData {
return {
position: 0,
+ display: 0,
flexGrow: 0,
flexShrink: 0,
alignSelf: 0,
diff --git a/sdk/src/ptrLayouts.generated.ts b/sdk/src/ptrLayouts.generated.ts
index a5e2673aa..5c47efd41 100644
--- a/sdk/src/ptrLayouts.generated.ts
+++ b/sdk/src/ptrLayouts.generated.ts
@@ -335,6 +335,7 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
ptrFn: 'getUINodePtr',
fields: [
{ name: 'position', type: 'u8', offset: 0 },
+ { name: 'display', type: 'u8', offset: 1 },
{ name: 'flexGrow', type: 'f32', offset: 52 },
{ name: 'flexShrink', type: 'f32', offset: 56 },
{ name: 'alignSelf', type: 'u8', offset: 68 },
diff --git a/sdk/src/ui/core/ui-node.ts b/sdk/src/ui/core/ui-node.ts
index 51b851684..c871d4318 100644
--- a/sdk/src/ui/core/ui-node.ts
+++ b/sdk/src/ui/core/ui-node.ts
@@ -5,11 +5,9 @@
* @brief UINode — the CSS box-model layout primitive.
*
* The primary way to author UI geometry: every size is a {@link Dimension}
- * (px / percent / auto) fed straight into the single-pass Yoga solver, replacing
- * the RectTransform anchor/offset/pivot model. The per-item flex properties
- * (grow/shrink/basis/alignSelf/margin/min-max) live here — the standalone
- * FlexItem component was subsumed by UINode and removed.
- * Container properties stay on {@link FlexContainer}. Mirrors the C++ `UINode`
+ * (px / percent / auto) fed straight into the single-pass Yoga solver. The
+ * per-item flex properties (grow/shrink/basis/alignSelf/margin/min-max) live
+ * here; container properties stay on {@link FlexContainer}. Mirrors the C++ `UINode`
* builtin; `computed_size_` is C++-internal (not serialized). Construct lengths
* with `px()/percent()/auto()`.
*/
@@ -20,11 +18,15 @@ import { auto, px, type Dimension } from './dimension';
// `inset` against the parent box — covers the old RectTransform anchor/stretch
// cases) and per-item cross-axis alignment override. Both single-sourced from
// the C++ ES_ENUMs via the generated module.
-export { UIPositionType, AlignSelf } from '../../wasm.generated';
+export { UIPositionType, UIDisplay, AlignSelf } from '../../wasm.generated';
export interface UINodeData {
/** Relative (flex flow) or Absolute (placed by inset). */
position: number;
+ /** CSS `display` (UIDisplay). None removes this node AND its whole subtree
+ * from layout, rendering and hit-testing — the hierarchical show/hide.
+ * Contrast with UIVisual.enabled, which hides only this entity's visual. */
+ display: number;
/** Box size; `auto()` = content-/flex-driven. */
width: Dimension;
height: Dimension;
@@ -54,6 +56,7 @@ export interface UINodeData {
export const UINode = defineBuiltin<UINodeData>('UINode', {
position: 0,
+ display: 0,
width: auto(),
height: auto(),
minWidth: auto(),
diff --git a/sdk/src/ui/index.ts b/sdk/src/ui/index.ts
index f7e05b647..52b15761a 100644
--- a/sdk/src/ui/index.ts
+++ b/sdk/src/ui/index.ts
@@ -45,7 +45,7 @@ export {
// ─── Layer 1: Primitives ────────────────────────────────────────────────────
export { DimensionUnit, type Dimension, px, percent, auto, isAuto } from './core/dimension';
-export { UINode, UIPositionType, AlignSelf, type UINodeData } from './core/ui-node';
+export { UINode, UIPositionType, UIDisplay, AlignSelf, type UINodeData } from './core/ui-node';
export {
UIVisual,
diff --git a/sdk/src/ui/text/plugin.ts b/sdk/src/ui/text/plugin.ts
index 69def106f..29b05b52e 100644
--- a/sdk/src/ui/text/plugin.ts
+++ b/sdk/src/ui/text/plugin.ts
@@ -105,6 +105,8 @@ export class TextPlugin implements Plugin {
const t = world.get(entity, Text) as TextData;
// enabled === false: pre-upgrade data lacks the field → visible.
if (!t.content || t.enabled === false) continue;
+ // display:none anywhere up the UI tree hides this text too.
+ if (module.getUINodeHiddenInTree?.(registry, entity)) continue;
seen.add(entity as number);
const tr = world.get(entity, Transform) as TransformData;
diff --git a/sdk/src/ui/widgets/dialog.ts b/sdk/src/ui/widgets/dialog.ts
index d6772f730..854ff70d2 100644
--- a/sdk/src/ui/widgets/dialog.ts
+++ b/sdk/src/ui/widgets/dialog.ts
@@ -5,7 +5,8 @@ import type { World } from '../../world';
import { Interactable, UIInteraction } from '../input/interactable';
-import { spawnUIEntity, setUIVisible, type UINodeInit, type UIVisualInit } from './helpers';
+import { spawnUIEntity, type UINodeInit, type UIVisualInit } from './helpers';
+import { UINode, UIDisplay, type UINodeData } from '../core/ui-node';
import { px, percent } from '../core/dimension';
import { themeColors } from '../theme/tokens';
import { markThemed } from '../theme/theme-style';
@@ -82,20 +83,13 @@ export function createDialog(opts: DialogOptions): DialogHandle {
let open = !(opts.startHidden ?? true);
applyOpen(open);
+ // display:none removes the backdrop AND everything the user parented under
+ // the panel from layout, rendering and hit-testing in one write — closing
+ // must hide user content too, not just the two entities we own.
function applyOpen(value: boolean): void {
- setUIVisible(world, backdrop, value);
- setUIVisible(world, panel, value);
- // Disable the backdrop's raycast blocker when hidden so clicks
- // fall through to scene behind.
- if (world.has(backdrop, Interactable)) {
- const i = world.get(backdrop, Interactable) as {
- enabled: boolean;
- blockRaycast: boolean;
- raycastTarget: boolean;
- };
- i.enabled = value;
- world.insert(backdrop, Interactable, i);
- }
+ const node = world.get(backdrop, UINode) as UINodeData;
+ node.display = value ? UIDisplay.Flex : UIDisplay.None;
+ world.insert(backdrop, UINode, node);
}
return {
diff --git a/sdk/src/ui/widgets/helpers.ts b/sdk/src/ui/widgets/helpers.ts
index ed3fc976c..824883ec6 100644
--- a/sdk/src/ui/widgets/helpers.ts
+++ b/sdk/src/ui/widgets/helpers.ts
@@ -7,7 +7,7 @@ import {
import type { Entity, Vec2 } from '../../types';
import type { World } from '../../world';
-import { UINode, UIPositionType, type UINodeData } from '../core/ui-node';
+import { UINode, UIPositionType, UIDisplay, type UINodeData } from '../core/ui-node';
import { px, percent, auto, type Dimension } from '../core/dimension';
import { UIVisual, UIVisualType, FillMethod, FillOrigin, type UIVisualData } from '../core/ui-visual';
import { Text, TextAlign, TextVerticalAlign, TextRenderMode, type TextData } from '../core/text';
@@ -52,6 +52,7 @@ export function buildUINode(init: UINodeInit = {}): UINodeData {
const fill = init.fill ?? false;
return {
position: init.position ?? (fill ? UIPositionType.Absolute : UIPositionType.Relative),
+ display: UIDisplay.Flex,
width: init.width ?? auto(),
height: init.height ?? auto(),
minWidth: auto(),
diff --git a/sdk/src/wasm.generated.ts b/sdk/src/wasm.generated.ts
index a3bb9ca24..2c96ec410 100644
--- a/sdk/src/wasm.generated.ts
+++ b/sdk/src/wasm.generated.ts
@@ -137,6 +137,11 @@ export enum TextAlign {
Right = 2,
}
+export enum UIDisplay {
+ Flex = 0,
+ None = 1,
+}
+
export enum UIFillMethod {
Horizontal = 0,
Vertical = 1,
@@ -453,6 +458,7 @@ export interface UIMask {
export interface UINode {
position: number;
+ display: number;
width: Dimension;
height: Dimension;
minWidth: Dimension;
diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.ts
index a8ae0d4fc..6a97b3517 100644
--- a/sdk/src/wasm.ts
+++ b/sdk/src/wasm.ts
@@ -418,6 +418,7 @@ export interface ESEngineModule {
uiFlexLayout_update(registry: CppRegistry): void;
getUINodeComputedWidth?(registry: CppRegistry, entity: number): number;
getUINodeComputedHeight?(registry: CppRegistry, entity: number): number;
+ getUINodeHiddenInTree?(registry: CppRegistry, entity: number): boolean;
uiTree_markStructureDirty(): void;
uiTree_markDirty(entity: number): void;
uiTree_markAllDirty(): void;
diff --git a/sdk/tests/emscripten-wrapper.test.ts b/sdk/tests/emscripten-wrapper.test.ts
index 76793e8a6..66016b2db 100644
--- a/sdk/tests/emscripten-wrapper.test.ts
+++ b/sdk/tests/emscripten-wrapper.test.ts
@@ -21,6 +21,7 @@ const auto = () => ({ value: 0, unit: 2 });
function fullNode(over: Partial<UINodeData> = {}): UINodeData {
return {
position: 0,
+ display: 0,
width: auto(), height: auto(),
minWidth: auto(), minHeight: auto(),
maxWidth: auto(), maxHeight: auto(),
diff --git a/sdk/tests/ui-widgets.test.ts b/sdk/tests/ui-widgets.test.ts
index a09f15f31..85c07feca 100644
--- a/sdk/tests/ui-widgets.test.ts
+++ b/sdk/tests/ui-widgets.test.ts
@@ -19,6 +19,7 @@ import {
FillOrigin,
UIEventQueue,
UIEventType,
+ UIDisplay,
themeColors,
type UIControllerData,
type UIGearData,
@@ -412,34 +413,34 @@ describe('createDialog', () => {
world = createMockWorld();
});
- it('starts hidden by default', () => {
+ it('starts hidden by default — backdrop subtree is display:none', () => {
const dialog = createDialog({ world: world as unknown as World });
expect(dialog.isOpen()).toBe(false);
- const bg = world.get(dialog.backdropEntity, UIVisual) as { enabled: boolean };
- expect(bg.enabled).toBe(false);
+ const bg = world.get(dialog.backdropEntity, UINode) as { display: number };
+ expect(bg.display).toBe(UIDisplay.None);
});
- it('open() shows backdrop + panel and enables Interactable', () => {
+ it('open() restores display:flex on the backdrop root', () => {
const dialog = createDialog({ world: world as unknown as World });
dialog.open();
expect(dialog.isOpen()).toBe(true);
- const bg = world.get(dialog.backdropEntity, UIVisual) as { enabled: boolean };
- const panel = world.get(dialog.panelEntity, UIVisual) as { enabled: boolean };
+ const bg = world.get(dialog.backdropEntity, UINode) as { display: number };
+ expect(bg.display).toBe(UIDisplay.Flex);
+ // The blocker stays enabled permanently — display:none already removes
+ // the whole subtree from hit-testing while closed.
const inter = world.get(dialog.backdropEntity, Interactable) as { enabled: boolean };
- expect(bg.enabled).toBe(true);
- expect(panel.enabled).toBe(true);
expect(inter.enabled).toBe(true);
});
- it('close() hides and disables the backdrop Interactable', () => {
+ it('close() sets display:none so user children under the panel vanish too', () => {
const dialog = createDialog({ world: world as unknown as World, startHidden: false });
expect(dialog.isOpen()).toBe(true);
dialog.close();
- const inter = world.get(dialog.backdropEntity, Interactable) as { enabled: boolean };
expect(dialog.isOpen()).toBe(false);
- expect(inter.enabled).toBe(false);
+ const bg = world.get(dialog.backdropEntity, UINode) as { display: number };
+ expect(bg.display).toBe(UIDisplay.None);
});
it('dispose despawns the backdrop', () => {
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 944e1c0c6..3e3ea62a5 100644
--- a/src/esengine/bindings/EditorAPI.generated.cpp
+++ b/src/esengine/bindings/EditorAPI.generated.cpp
@@ -2,10 +2,10 @@
* @file EditorAPI.generated.cpp
* @brief Auto-generated editor API with string-dispatched component access
* @details Generated by EHT - DO NOT EDIT
- * @schema_hash ab9dd9b394a07d42
+ * @schema_hash 1f7fbdd80441c044
*/
-#define ES_EDITOR_API_SCHEMA_HASH "ab9dd9b394a07d42"
+#define ES_EDITOR_API_SCHEMA_HASH "1f7fbdd80441c044"
#include <emscripten/bind.h>
#include <string>
@@ -443,6 +443,7 @@ std::string editor_getComponentSchema(const std::string& name) {
} else if (name == "UINode") {
return R"JSON([
{"key":"position","type":"enum","group":"UINode","values":["Relative","Absolute"]},
+ {"key":"display","type":"enum","group":"UINode","values":["Flex","None"]},
{"key":"width.value","type":"float","group":"UINode"},
{"key":"width.unit","type":"float","group":"UINode"},
{"key":"height.value","type":"float","group":"UINode"},
@@ -1558,6 +1559,7 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::str
if (!reg.has<esengine::ecs::UINode>(entity)) return false;
auto& c = reg.get<esengine::ecs::UINode>(entity);
if (field == "position") { c.position = static_cast<UIPositionType>(value); }
+ else if (field == "display") { c.display = static_cast<UIDisplay>(value); }
else if (field == "alignSelf") { c.alignSelf = static_cast<AlignSelf>(value); }
else { return false; }
return true;
@@ -1695,6 +1697,7 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::stri
if (!reg.has<esengine::ecs::UINode>(entity)) return 0;
const auto& c = reg.get<esengine::ecs::UINode>(entity);
if (field == "position") { return static_cast<i32>(c.position); }
+ else if (field == "display") { return static_cast<i32>(c.display); }
else if (field == "alignSelf") { return static_cast<i32>(c.alignSelf); }
} else if (comp == "UIVisual") {
if (!reg.has<esengine::ecs::UIVisual>(entity)) return 0;
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index 1da8b58da..a0826d84a 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -776,6 +776,11 @@ void uiTree_markAllDirty() {
// UINode (CSS box) computed size — its internal computed_size_ is not
// embind-readable, so expose it for TS uiHelpers.
+bool getUINodeHiddenInTree(ecs::Registry& registry, u32 entity) {
+ auto* node = registry.tryGet<ecs::UINode>(Entity::fromRaw(entity));
+ return node && node->hidden_in_tree_;
+}
+
f32 getUINodeComputedWidth(ecs::Registry& registry, u32 entity) {
auto* node = registry.tryGet<ecs::UINode>(Entity::fromRaw(entity));
if (!node) return 0.0f;
@@ -820,6 +825,7 @@ EMSCRIPTEN_BINDINGS(esengine_ui_systems) {
emscripten::function("uiRenderOrder_update", &esengine::uiRenderOrder_update);
emscripten::function("ui_getRenderOrder", &esengine::ui_getRenderOrder);
emscripten::function("uiFlexLayout_update", &esengine::uiFlexLayout_update);
+ emscripten::function("getUINodeHiddenInTree", &esengine::getUINodeHiddenInTree);
emscripten::function("getUINodeComputedWidth", &esengine::getUINodeComputedWidth);
emscripten::function("getUINodeComputedHeight", &esengine::getUINodeComputedHeight);
emscripten::function("uiTree_markStructureDirty", &esengine::uiTree_markStructureDirty);
diff --git a/src/esengine/ecs/UILayoutSystem.cpp b/src/esengine/ecs/UILayoutSystem.cpp
index c2e559f37..a5a6298e4 100644
--- a/src/esengine/ecs/UILayoutSystem.cpp
+++ b/src/esengine/ecs/UILayoutSystem.cpp
@@ -141,6 +141,8 @@ void applyInset(YGNodeRef n, YGEdge edge, const Dimension& d) {
void applyUINodeStyle(Registry& registry, Entity entity, YGNodeRef yg) {
auto& n = registry.get<UINode>(entity);
+ YGNodeStyleSetDisplay(yg, n.display == UIDisplay::None
+ ? YGDisplayNone : YGDisplayFlex);
YGNodeStyleSetPositionType(yg, n.position == UIPositionType::Absolute
? YGPositionTypeAbsolute : YGPositionTypeRelative);
applyInset(yg, YGEdgeLeft, n.insetLeft);
@@ -271,6 +273,26 @@ void layoutUINodeSubtree(
YGNodeFreeRecursive(rootYG);
}
+// Resolve display:none hierarchically over the DFS-ordered tree: a node with
+// display None hides its whole subtree. Rendering, text and hit-testing read
+// the resulting UINode.hidden_in_tree_ bit so they never need tree knowledge.
+void propagateHiddenInTree(Registry& registry, UITree& tree) {
+ auto& nodes = tree.nodes_;
+ for (i32 i = 0; i < static_cast<i32>(nodes.size()); ) {
+ auto* n = registry.tryGet<UINode>(nodes[i].entity);
+ if (n && n->display == UIDisplay::None) {
+ i32 end = i + nodes[i].subtree_size;
+ for (i32 k = i; k < end; ++k) {
+ if (auto* c = registry.tryGet<UINode>(nodes[k].entity)) c->hidden_in_tree_ = true;
+ }
+ i = end;
+ } else {
+ if (n) n->hidden_in_tree_ = false;
+ ++i;
+ }
+ }
+}
+
void unifiedLayoutPass(Registry& registry, UITree& tree, const LayoutRect& cameraRect) {
for (i32 i = 0; i < static_cast<i32>(tree.nodes_.size()); ) {
auto& node = tree.nodes_[i];
@@ -304,6 +326,7 @@ void UISystem::layoutUpdate(
f32 camLeft, f32 camBottom, f32 camRight, f32 camTop
) {
tree.rebuild(registry);
+ propagateHiddenInTree(registry, tree);
LayoutRect cameraRect{ camLeft, camBottom, camRight, camTop };
unifiedLayoutPass(registry, tree, cameraRect);
}
diff --git a/src/esengine/ecs/UISystem.cpp b/src/esengine/ecs/UISystem.cpp
index 5021411a0..819b7c03b 100644
--- a/src/esengine/ecs/UISystem.cpp
+++ b/src/esengine/ecs/UISystem.cpp
@@ -49,7 +49,7 @@ void UISystem::hitTestUpdate(
// Hit geometry from the UINode (CSS box, pivot-centered).
auto* node = registry.tryGet<UINode>(entity);
- if (!node) continue;
+ if (!node || node->hidden_in_tree_) continue;
f32 baseW = node->computed_size_.x;
f32 baseH = node->computed_size_.y;
f32 pivotX = 0.5f, pivotY = 0.5f;
diff --git a/src/esengine/ecs/components/UINode.hpp b/src/esengine/ecs/components/UINode.hpp
index 4afe6bca1..63e46bdb8 100644
--- a/src/esengine/ecs/components/UINode.hpp
+++ b/src/esengine/ecs/components/UINode.hpp
@@ -36,6 +36,18 @@ enum class UIPositionType : u8 {
Absolute
};
+/**
+ * @brief CSS `display`. None removes the node AND its whole subtree from
+ * layout, rendering, and hit-testing — the hierarchical show/hide
+ * primitive (a closed dialog, a collapsed panel). Contrast with
+ * UIVisual.enabled, which hides only that entity's own visual.
+ */
+ES_ENUM()
+enum class UIDisplay : u8 {
+ Flex,
+ None
+};
+
/**
* @brief UINode — the CSS box-model layout input (the CSS/Flex
* primary layout model).
@@ -56,6 +68,9 @@ struct UINode {
ES_PROPERTY()
UIPositionType position{UIPositionType::Relative};
+ ES_PROPERTY(tooltip="None removes this node and its whole subtree from layout, rendering and input.")
+ UIDisplay display{UIDisplay::Flex};
+
// Box size; auto = content-/flex-driven.
ES_PROPERTY()
Dimension width{0.0f, 2};
@@ -105,6 +120,11 @@ struct UINode {
// Layout output (not serialized): resolved px size written by the Yoga pass.
glm::vec2 computed_size_{0.0f};
+ // Computed (not serialized): true when this node or any ancestor has
+ // display None. Written by the layout pass; read by rendering, text and
+ // hit-testing so the whole subtree disappears from all three.
+ bool hidden_in_tree_{false};
+
// Set by the tween system for Transform fields it drives, so the layout pass
// leaves those fields alone this frame (cleared each frame).
u8 anim_override_{0};
diff --git a/src/esengine/renderer/plugins/UIElementPlugin.cpp b/src/esengine/renderer/plugins/UIElementPlugin.cpp
index c5f59f481..f7969c9f9 100644
--- a/src/esengine/renderer/plugins/UIElementPlugin.cpp
+++ b/src/esengine/renderer/plugins/UIElementPlugin.cpp
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
#include "UIElementPlugin.hpp"
+#include "../MaterialStore.hpp"
#include "../RenderContext.hpp"
#include "../RenderFrame.hpp"
#include "../Texture.hpp"
@@ -57,7 +58,7 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {
// Geometry from the UINode (CSS box) — always pivot-centered.
const auto* node = registry.tryGet<ecs::UINode>(entity);
- if (!node) continue;
+ if (!node || node->hidden_in_tree_) continue;
f32 w = node->computed_size_.x, h = node->computed_size_.y;
f32 pivotX = 0.5f, pivotY = 0.5f;
if (w <= 0.0f && h <= 0.0f) continue;
@@ -199,6 +200,19 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {
.type = RenderType::UIElement,
};
+ // Same resolution as SpritePlugin: an unregistered handle falls back to
+ // the default batch shader, so a dangling material renders plainly.
+ if (renderer.material != 0) {
+ if (const MaterialRecord* m = ctx.materials ? ctx.materials->find(renderer.material) : nullptr) {
+ key.shaderId = (m->shader != 0) ? m->shader : batch_shader_id_;
+ key.blend = m->blend;
+ key.materialId = renderer.material;
+ key.depthTest = m->depthTest;
+ key.depthWrite = m->depthWrite;
+ key.cull = static_cast<u8>(m->cull);
+ }
+ }
+
constexpr glm::vec2 CENTERED_PIVOT{0.5f, 0.5f};
if (isRadialFill) {