ComputedNode's size returns 0.0 with Added filter in Query #17997
-
I'm trying to get width & height of a Node, but fn my_system(query: Query<(&ComputedNode, &Node), Added<MyComponent>>) {
for (computed_node, node) in query.iter() {
println!("{:?}", computed_node.size()); // always return Vec2(0.0, 0.0)
println!("{:?}", node.width); // Val::Percent(100.0)
}
} If i remove |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
My guess is that
And you should see that the first frame it prints |
Beta Was this translation helpful? Give feedback.
My guess is that
my_system
is running beforeui_layout_system
has updated theComputedNode
's size the first time.And without the filter it prints out the size every frame so the last size it prints out will be non-zero.
Try changing
my_system
's query filter to:And you should see that the first frame it prints
Vec2(0.0, 0.0)
and then the next frame it prints the computed size of the node.