Skip to content

Commit

Permalink
prevent text2d system from interfering with UI text handling
Browse files Browse the repository at this point in the history
  • Loading branch information
blunted2night committed Dec 29, 2020
1 parent 0802f20 commit 4ac0d58
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/bevy_text/src/text2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ use crate::{
CalculatedSize, DefaultTextPipeline, DrawableText, Font, FontAtlasSet, Text, TextError,
};

/// Marker to identify entities as "Text2d"
#[derive(Clone, Default, Debug)]
pub struct Text2d;

/// The bundle of components needed to draw text in a 2D scene via the Camera2dBundle.
#[derive(Bundle, Clone, Debug)]
pub struct Text2dBundle {
Expand All @@ -26,6 +30,7 @@ pub struct Text2dBundle {
pub global_transform: GlobalTransform,
pub main_pass: MainPass,
pub calculated_size: CalculatedSize,
pub text2d: Text2d,
}

impl Default for Text2dBundle {
Expand All @@ -45,6 +50,7 @@ impl Default for Text2dBundle {
calculated_size: CalculatedSize {
size: Size::default(),
},
text2d: Default::default(),
}
}
}
Expand All @@ -67,7 +73,7 @@ pub fn draw_text2d_system(
&GlobalTransform,
&CalculatedSize,
),
With<MainPass>,
With<(Text2d,MainPass)>,
>,
) {
let font_quad = meshes.get(&QUAD_HANDLE).unwrap();
Expand Down Expand Up @@ -122,8 +128,8 @@ pub fn text2d_system(
mut font_atlas_set_storage: ResMut<Assets<FontAtlasSet>>,
mut text_pipeline: ResMut<DefaultTextPipeline>,
mut text_queries: QuerySet<(
Query<Entity, Changed<Text>>,
Query<(&Text, &mut CalculatedSize)>,
Query<Entity, (With<Text2d>,Changed<Text>)>,
Query<(&Text, &mut CalculatedSize), With<Text2d>>,
)>,
) {
// Adds all entities where the text or the style has changed to the local queue
Expand Down

0 comments on commit 4ac0d58

Please sign in to comment.