Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions crates/bevy_dev_tools/src/fps_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_ecs::{
query::{With, Without},
reflect::ReflectResource,
resource::Resource,
schedule::{common_conditions::resource_changed, IntoScheduleConfigs},
schedule::{common_conditions::resource_changed, IntoScheduleConfigs, SystemSet},
system::{Commands, Query, Res, ResMut, Single},
};
use bevy_picking::Pickable;
Expand Down Expand Up @@ -56,6 +56,15 @@ pub struct FpsOverlayPlugin {
pub config: FpsOverlayConfig,
}

/// System sets for FPS overlay updates.
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
pub enum FpsOverlaySystems {
/// Applies config changes to the overlay UI.
Customize,
/// Updates the overlay contents.
UpdateText,
}

impl Plugin for FpsOverlayPlugin {
fn build(&self, app: &mut bevy_app::App) {
// TODO: Use plugin dependencies, see https://github.com/bevyengine/bevy/issues/69
Expand All @@ -76,13 +85,20 @@ impl Plugin for FpsOverlayPlugin {
}

app.insert_resource(self.config.clone())
.configure_sets(
Update,
FpsOverlaySystems::Customize.before(FpsOverlaySystems::UpdateText),
)
.add_systems(Startup, setup)
.add_systems(
Update,
(
(toggle_display, customize_overlay)
.run_if(resource_changed::<FpsOverlayConfig>),
update_text.run_if(on_timer(self.config.refresh_interval)),
.run_if(resource_changed::<FpsOverlayConfig>)
.in_set(FpsOverlaySystems::Customize),
update_text
.run_if(on_timer(self.config.refresh_interval))
.in_set(FpsOverlaySystems::UpdateText),
),
);
}
Expand Down
12 changes: 9 additions & 3 deletions crates/bevy_dev_tools/src/frame_time_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
use bevy_app::{Plugin, Update};
use bevy_asset::{load_internal_asset, uuid_handle, Asset, Assets, Handle};
use bevy_diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
use bevy_ecs::system::{Res, ResMut};
use bevy_ecs::{
schedule::IntoScheduleConfigs,
system::{Res, ResMut},
};
use bevy_math::ops::log2;
use bevy_reflect::TypePath;
use bevy_render::{
Expand All @@ -13,7 +16,7 @@ use bevy_render::{
use bevy_shader::{Shader, ShaderRef};
use bevy_ui_render::prelude::{UiMaterial, UiMaterialPlugin};

use crate::fps_overlay::FpsOverlayConfig;
use crate::fps_overlay::{FpsOverlayConfig, FpsOverlaySystems};

const FRAME_TIME_GRAPH_SHADER_HANDLE: Handle<Shader> =
uuid_handle!("4e38163a-5782-47a5-af52-d9161472ab59");
Expand All @@ -37,7 +40,10 @@ impl Plugin for FrameTimeGraphPlugin {
}

app.add_plugins(UiMaterialPlugin::<FrametimeGraphMaterial>::default())
.add_systems(Update, update_frame_time_values);
.add_systems(
Update,
update_frame_time_values.in_set(FpsOverlaySystems::UpdateText),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there are any remaining problems, but I'm a bit unclear as to whether FrameTimeGraphPlugin is meant to be able to run independently of FpsOverlayPlugin or not. I guess it doesn't matter for this PR.

);
}
}

Expand Down