diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index 38e10ec312..358a7f2045 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -8,6 +8,7 @@ use bevy_ecs::{ change_detection::DetectChangesMut, component::Component, entity::Entity, + prelude::Local, query::With, resource::Resource, schedule::{common_conditions::resource_changed, IntoSystemConfigs}, @@ -15,10 +16,12 @@ use bevy_ecs::{ }; use bevy_render::view::Visibility; use bevy_text::{Font, TextColor, TextFont, TextSpan}; +use bevy_time::Time; use bevy_ui::{ widget::{Text, TextUiWriter}, GlobalZIndex, Node, PositionType, }; +use core::time::Duration; /// [`GlobalZIndex`] used to render the fps overlay. /// @@ -65,6 +68,10 @@ pub struct FpsOverlayConfig { pub text_color: Color, /// Displays the FPS overlay if true. pub enabled: bool, + /// The period after which the FPS overlay re-renders. + /// + /// Defaults to once every 100 ms. + pub refresh_interval: Duration, } impl Default for FpsOverlayConfig { @@ -77,6 +84,7 @@ impl Default for FpsOverlayConfig { }, text_color: Color::WHITE, enabled: true, + refresh_interval: Duration::from_millis(100), } } } @@ -110,11 +118,18 @@ fn update_text( diagnostic: Res, query: Query>, mut writer: TextUiWriter, + time: Res