Skip to content

Commit 2f63ebc

Browse files
Remove warning for children in UI hierarchies without Style (#15736)
# Objective As discussed in #15591, this warning prevents us from storing leaf nodes without a `Style` component. Because text sections (as distinct entities) should not be laid out using `taffy`, this warning is incorrect. Users may also have other uses for doing this, and this should generally increase flexibility without posing particularly serious correctness concerns. ## Solution - removed warning about non-UI children with UI parents - improved the warning about UI parents with non-UI parents - this warning should stay, for now, as it results in a genuine failure to perform `taffy` layout - that said, we should be clearer about the cause and potentially harmful results of this! ## Testing I inserted an empty entity into the hierarchy in the `button` example as a leaf node, and it ran with no warnings.
1 parent e563f86 commit 2f63ebc

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

crates/bevy_ui/src/layout/ui_surface.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ impl UiSurface {
121121
for child in children {
122122
if let Some(taffy_node) = self.entity_to_taffy.get(&child) {
123123
self.taffy_children_scratch.push(*taffy_node);
124-
} else {
125-
warn!(
126-
"Unstyled child `{child}` in a UI entity hierarchy. You are using an entity \
127-
without UI components as a child of an entity with UI components, results may be unexpected. \
128-
If this is intentional, consider adding a GhostNode component to this entity."
129-
);
130124
}
131125
}
132126

@@ -296,8 +290,8 @@ If this is intentional, consider adding a GhostNode component to this entity."
296290
.map_err(LayoutError::TaffyError)
297291
} else {
298292
warn!(
299-
"Styled child in a non-UI entity hierarchy. You are using an entity \
300-
with UI components as a child of an entity without UI components, results may be unexpected."
293+
"Styled child ({entity}) in a non-UI entity hierarchy. You are using an entity \
294+
with UI components as a child of an entity without UI components, your UI layout may be broken."
301295
);
302296
Err(LayoutError::InvalidHierarchy)
303297
}

0 commit comments

Comments
 (0)