6 releases
new 0.16.0 | May 8, 2025 |
---|---|
0.15.1 | Apr 3, 2025 |
0.15.0 | Nov 30, 2024 |
0.14.2 | Aug 6, 2024 |
#526 in Game dev
102 downloads per month
33KB
103 lines
bevy_debug_panel
add debug info to screen
Quickstart
simple show framerate example
use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
use bevy::prelude::*;
use bevy_debug_panel::prelude::*;
const MAX_HISTORY_LENGTH: usize = 16;
const SMOOTHING_FACTOR: f64 = 2.0 / (MAX_HISTORY_LENGTH + 1) as f64;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(DebugPanelPlugin)
.add_plugins(FrameTimeDiagnosticsPlugin {
max_history_length: MAX_HISTORY_LENGTH,
smoothing_factor: SMOOTHING_FACTOR,
})
.insert_resource(ClearColor(Color::srgb(0.5, 0.5, 0.9)))
.add_systems(Startup, setup)
.add_systems(Update, show_fps)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);
}
fn show_fps(diagnostics: Res<DiagnosticsStore>, mut debug_res: ResMut<DebugResource>) {
if let Some(value) = diagnostics
.get(&FrameTimeDiagnosticsPlugin::FPS)
.and_then(|fps| fps.smoothed())
{
debug_res.insert("Fps", format!("{:.2}", value));
}
}
compatible bevy versions
bevy | bevy_debug_panel |
---|---|
0.14 | 0.14 |
0.15 | 0.15 |
Dependencies
~58–91MB
~1.5M SLoC