From dd3b6b1346e20628b871fa1712ebdfcb146d27e9 Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Thu, 28 Sep 2023 17:45:19 -0400 Subject: [PATCH] Use Bevy's FrameTimeDiagnostics for FPS counter --- hello-world/src/ui.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/hello-world/src/ui.rs b/hello-world/src/ui.rs index 97c6729..89c20a6 100644 --- a/hello-world/src/ui.rs +++ b/hello-world/src/ui.rs @@ -1,10 +1,15 @@ -use bevy::prelude::*; +use bevy::{ + diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, + prelude::*, +}; pub struct UiLayerPlugin; impl Plugin for UiLayerPlugin { fn build(&self, app: &mut App) { - app.add_systems(Startup, layout).add_systems(Update, update); + app.add_plugins(FrameTimeDiagnosticsPlugin) + .add_systems(Startup, layout) + .add_systems(Update, update); } } @@ -42,9 +47,19 @@ fn layout(mut cmd: Commands) { }); } -fn update(time: Res