Path: blob/main/examples/diagnostics/enabling_disabling_diagnostic.rs
6592 views
//! Shows how to disable/re-enable a Diagnostic during runtime12use std::time::Duration;34use bevy::{5diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},6prelude::*,7time::common_conditions::on_timer,8};910fn main() {11App::new()12.add_plugins((13DefaultPlugins,14FrameTimeDiagnosticsPlugin::default(),15LogDiagnosticsPlugin::default(),16))17.add_systems(18Update,19toggle.run_if(on_timer(Duration::from_secs_f32(10.0))),20)21.run();22}2324fn toggle(mut store: ResMut<DiagnosticsStore>) {25for diag in store.iter_mut() {26info!("toggling diagnostic {}", diag.path());27diag.is_enabled = !diag.is_enabled;28}29}303132