Skip to content

Commit

Permalink
use run_if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
matiqo15 committed Mar 8, 2024
1 parent e237531 commit edb1846
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/bevy_dev_tools/src/fps_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use bevy_ecs::{
change_detection::DetectChanges,
component::Component,
query::With,
schedule::{common_conditions::resource_changed, IntoSystemConfigs},
system::{Commands, Query, Res, Resource},
};
use bevy_input::{keyboard::KeyCode, ButtonInput};
Expand All @@ -27,7 +28,14 @@ impl Plugin for FpsOverlayPlugin {
}
app.insert_resource(self.config.clone())
.add_systems(Startup, setup)
.add_systems(Update, (customize_text, update_text, toggle_overlay));
.add_systems(
Update,
(
customize_text.run_if(resource_changed::<FpsOverlayConfig>),
update_text,
toggle_overlay,
),
);
}
}

Expand Down Expand Up @@ -121,10 +129,6 @@ fn customize_text(
asset_server: Res<AssetServer>,
mut query: Query<&mut Text, With<FpsText>>,
) {
if !overlay_config.is_changed() {
return;
}

for mut text in &mut query {
for section in text.sections.iter_mut() {
section.style = if let Some(font_path) = &overlay_config.font_path {
Expand Down

0 comments on commit edb1846

Please sign in to comment.