bevy_screen_diags 0.7.0

An on-screen FPS display for bevyengine.org
Documentation
//! This example illustrates how to customize the font or position of the FPS display.

use bevy::prelude::*;

use bevy_screen_diags::{ScreenDiagsText, ScreenDiagsTextPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Include the plugin
        .add_plugins(ScreenDiagsTextPlugin)
        .add_systems(Startup, setup)
        .add_systems(PostStartup, (tweak_fps_font, tweak_fps_position))
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d::default());
}

fn tweak_fps_font(mut text_query: Query<(&mut TextFont, &mut TextColor), With<ScreenDiagsText>>) {
    if let Ok(mut text) = text_query.single_mut() {
        text.1.0 = Color::Srgba(Srgba::GREEN);
        text.0.font_size = 92.0;
    }
}

fn tweak_fps_position(mut style_query: Query<&mut Node, With<ScreenDiagsText>>) {
    if let Ok(mut style) = style_query.single_mut() {
        style.position_type = PositionType::Absolute;
        style.right = Val::Percent(0.0);
        style.bottom = Val::Percent(0.0);
    }
}