Skip to content

Commit 5edf2d2

Browse files
authored
Prevent ImageBundles from causing constant layout recalculations (#1299)
Prevent ImageBundles from causing constant layout recalculations
1 parent 32acbfb commit 5edf2d2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/bevy_ui/src/widget/image.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ pub fn image_node_system(
2727
.and_then(|material| material.texture.as_ref())
2828
.and_then(|texture_handle| textures.get(texture_handle))
2929
{
30-
calculated_size.size = Size {
30+
let size = Size {
3131
width: texture.size.width as f32,
3232
height: texture.size.height as f32,
3333
};
34+
// Update only if size has changed to avoid needless layout calculations
35+
if size != calculated_size.size {
36+
calculated_size.size = size;
37+
}
3438
}
3539
}
3640
}

0 commit comments

Comments
 (0)