Remove warning for children in UI hierarchies without Style#15736
Remove warning for children in UI hierarchies without Style#15736cart merged 2 commits intobevyengine:mainfrom
Conversation
|
This fix was much simpler than the more specific UI -> non-UI -> UI pattern that @cart called out as problematic here. I also think it's somewhat better, as non-UI -> UI still has not-particularly well defined behavior in general. We could treat that case as fine if and only if there's no UI root above it by treating it as the start of a new tree, but really that feels quite a bit more complex for users to reason about and will involve a more complex fix and ongoing validity checks. |
|
Waiting on an opinion from Cart before merging :) I want to make sure that this lines up with what he had in mind. |
cart
left a comment
There was a problem hiding this comment.
This fix was much simpler than the more specific UI -> non-UI -> UI pattern that @cart called out as problematic
Ah yeah this is definitely the right path forward conceptually. It being simpler / just removing code is icing on the cake!
# Objective With the warning removed in #15736, the rules for the UI tree changes. We no longer need to traverse non `Node`/`GhostNode` entities. ## Solution - Added a filter `Or<(With<Node>, With<GhostNode>)>` to the child traversal query so we don't unnecessarily traverse nodes that are not part of the UI tree (like text nodes). - Also moved the warning for NoUI->UI entities so it is actually triggered (see comments) ## Testing - Ran unit tests (still passing) - Ran the ghost_nodes and ui examples, still works and looks fine 👍 - Tested the warning by spawning a Node under an empty entity. --- --------- Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
Objective
As discussed in #15591, this warning prevents us from storing leaf nodes without a
Stylecomponent. Because text sections (as distinct entities) should not be laid out usingtaffy, 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
taffylayoutTesting
I inserted an empty entity into the hierarchy in the
buttonexample as a leaf node, and it ran with no warnings.