basic/
basic.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use bevy::prelude::*;

use bevy_fps_counter::{FpsCounter, FpsCounterPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(FpsCounterPlugin)
        .add_systems(Startup, setup)
        .add_systems(Update, mouse_handler)
        .run();
}

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

fn mouse_handler(
    mouse_button_input: Res<ButtonInput<MouseButton>>,
    mut diags_state: ResMut<FpsCounter>,
) {
    if mouse_button_input.pressed(MouseButton::Left) {
        if diags_state.is_enabled() {
            diags_state.disable();
        } else {
            diags_state.enable();
        }
    }
}