From ede91b8a2a6513742bce577fd6947aa646393a29 Mon Sep 17 00:00:00 2001 From: Mateusz Wachowiak Date: Sat, 9 Mar 2024 00:11:16 +0100 Subject: [PATCH] remove toggling overlay --- crates/bevy_dev_tools/src/fps_overlay.rs | 32 ++---------------------- examples/dev_tools/fps_overlay.rs | 11 +------- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index 2d4bbfa09ab0a..39e375bdae53e 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -8,8 +8,6 @@ use bevy_ecs::{ schedule::{common_conditions::resource_changed, IntoSystemConfigs}, system::{Commands, Query, Res, Resource}, }; -use bevy_input::{keyboard::KeyCode, ButtonInput}; -use bevy_render::view::Visibility; use bevy_text::{Text, TextSection, TextStyle}; use bevy_ui::node_bundles::TextBundle; @@ -32,7 +30,6 @@ impl Plugin for FpsOverlayPlugin { ( customize_text.run_if(resource_changed::), update_text, - toggle_overlay, ), ); } @@ -48,8 +45,6 @@ pub struct FpsOverlayConfig { pub font_size: f32, /// Color of the overlay text. pub font_color: Color, - /// Keybind for toggling on/off the overlay. - pub keybind: KeyCode, } impl Default for FpsOverlayConfig { @@ -58,7 +53,6 @@ impl Default for FpsOverlayConfig { font_path: None, font_size: 32.0, font_color: Color::WHITE, - keybind: KeyCode::F1, } } } @@ -107,14 +101,8 @@ fn setup( )); } -fn update_text( - diagnostic: Res, - mut query: Query<(&mut Text, &Visibility), With>, -) { - for (mut text, visibility) in &mut query { - if let Visibility::Hidden = *visibility { - return; - } +fn update_text(diagnostic: Res, mut query: Query<&mut Text, With>) { + for mut text in &mut query { if let Some(fps) = diagnostic.get(&FrameTimeDiagnosticsPlugin::FPS) { if let Some(value) = fps.smoothed() { text.sections[1].value = format!("{value:.2}"); @@ -146,19 +134,3 @@ fn customize_text( } } } - -fn toggle_overlay( - input: Res>, - mut query: Query<&mut Visibility, With>, - overlay_config: Res, -) { - if input.just_pressed(overlay_config.keybind) { - for mut visibility in query.iter_mut() { - *visibility = if let Visibility::Hidden = *visibility { - Visibility::Visible - } else { - Visibility::Hidden - } - } - } -} diff --git a/examples/dev_tools/fps_overlay.rs b/examples/dev_tools/fps_overlay.rs index 1f2c4910c6e44..a8c4717724fb4 100644 --- a/examples/dev_tools/fps_overlay.rs +++ b/examples/dev_tools/fps_overlay.rs @@ -17,8 +17,6 @@ fn main() { font_color: Color::srgb(0.0, 1.0, 0.0), // If we want, we can use a custom font font_path: None, - // This keybind will be toggling on/off the overlay - keybind: KeyCode::Escape, }, }, )) @@ -33,14 +31,7 @@ fn setup(mut commands: Commands) { commands.spawn( TextBundle::from_sections([ TextSection::new( - "Press ESC to toggle overlay", - TextStyle { - font_size: 25.0, - ..default() - }, - ), - TextSection::new( - "\nPress 1 to change color of the overlay.", + "Press 1 to change color of the overlay.", TextStyle { font_size: 25.0, ..default()