From 3f6968cd8a49b3bcc22af6ee72fe81c00d317d1f Mon Sep 17 00:00:00 2001 From: Catherine Gilbert Date: Tue, 13 Oct 2020 21:40:58 -0400 Subject: [PATCH 1/5] added frame count to FrameTimeDiagnosticsPlugin --- .../src/frame_time_diagnostics_plugin.rs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 2f48fe200b035..d5720b9aab694 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -3,32 +3,48 @@ use bevy_app::prelude::*; use bevy_core::Time; use bevy_ecs::{IntoQuerySystem, Res, ResMut}; -/// Adds "frame time" diagnostic to an App, specifically "frame time" and "fps" +/// Adds "frame time" diagnostic to an App, specifically "frame time", "fps" and "frame count" #[derive(Default)] pub struct FrameTimeDiagnosticsPlugin; +pub struct FrameTimeDiagnosticsState { + frame_count: f64 +} + impl Plugin for FrameTimeDiagnosticsPlugin { fn build(&self, app: &mut bevy_app::AppBuilder) { app.add_startup_system(Self::setup_system.system()) + .add_resource(FrameTimeDiagnosticsState { frame_count: 0.0 }) .add_system(Self::diagnostic_system.system()); } } impl FrameTimeDiagnosticsPlugin { - pub const FPS: DiagnosticId = DiagnosticId::from_u128(288146834822086093791974408528866909483); + pub const FPS: DiagnosticId = + DiagnosticId::from_u128(288146834822086093791974408528866909483); pub const FRAME_TIME: DiagnosticId = DiagnosticId::from_u128(54021991829115352065418785002088010276); + pub const FRAME_COUNT: DiagnosticId = + DiagnosticId::from_u128(54021991829115352065418785002088010277); pub fn setup_system(mut diagnostics: ResMut) { diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 20)); diagnostics.add(Diagnostic::new(Self::FPS, "fps", 20)); + diagnostics.add(Diagnostic::new(Self::FRAME_COUNT, "frame_count", 1)); } - pub fn diagnostic_system(mut diagnostics: ResMut, time: Res