work on lobby ui
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::ResourceInspectorPlugin};
|
||||
|
||||
use crate::lobby::LobbyUiState;
|
||||
|
||||
/// Whether the debug inspector is currently shown.
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct InspectorEnabled(bool);
|
||||
|
||||
pub struct DebugInspectorPlugin;
|
||||
|
||||
impl Plugin for DebugInspectorPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<InspectorEnabled>()
|
||||
.add_plugins(EguiPlugin::default())
|
||||
.add_plugins(
|
||||
ResourceInspectorPlugin::<LobbyUiState>::new()
|
||||
.run_if(|enabled: Res<InspectorEnabled>| enabled.0),
|
||||
)
|
||||
.add_systems(Update, toggle_inspector);
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_inspector(keys: Res<ButtonInput<KeyCode>>, mut enabled: ResMut<InspectorEnabled>) {
|
||||
if keys.just_pressed(KeyCode::F1) {
|
||||
enabled.0 = !enabled.0;
|
||||
info!("lobby ui inspector toggled {}", if enabled.0 { "on" } else { "off" });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user