From 62b2bbc2af850b6d8465b0dfc837cde9152072f7 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Tue, 28 Feb 2023 14:00:34 +0000 Subject: [PATCH] Text2d doesn't recompute text on changes to the text's bounds (#7846) # Objective Text2d entity's text needs to be recomputed when their bounds are changed, but it isn't. # Solution Change `update_text2d_layout` to query for `Ref` and recompute the text if the bounds have changed. --- crates/bevy_text/src/text2d.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index 26ecf5796ac2da..13f9d1340590fc 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -168,7 +168,7 @@ pub fn update_text2d_layout( mut text_query: Query<( Entity, Ref, - &Text2dBounds, + Ref, Option<&mut TextLayoutInfo>, )>, ) { @@ -182,7 +182,7 @@ pub fn update_text2d_layout( .unwrap_or(1.0); for (entity, text, bounds, text_layout_info) in &mut text_query { - if factor_changed || text.is_changed() || queue.remove(&entity) { + if factor_changed || text.is_changed() || bounds.is_changed() || queue.remove(&entity) { let text_bounds = Vec2::new( scale_value(bounds.size.x, scale_factor), scale_value(bounds.size.y, scale_factor),