upgrade to bevy 0.20
This commit is contained in:
+39
-10
@@ -1,7 +1,11 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::ResourceInspectorPlugin};
|
||||
|
||||
use crate::lobby::LobbyUiState;
|
||||
use bevy::prelude::*;
|
||||
use bevy_inspector_egui::{
|
||||
bevy_egui::EguiPlugin,
|
||||
quick::{ResourceInspectorPlugin, WorldInspectorPlugin},
|
||||
};
|
||||
|
||||
// TODO: compile these in only if debug build
|
||||
|
||||
/// Whether the debug inspector is currently shown.
|
||||
#[derive(Resource, Debug, Default)]
|
||||
@@ -13,20 +17,45 @@ impl Plugin for DebugInspectorPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<InspectorEnabled>()
|
||||
.add_plugins(EguiPlugin::default())
|
||||
.add_plugins(WorldInspectorPlugin::new())
|
||||
.add_plugins(
|
||||
ResourceInspectorPlugin::<LobbyUiState>::new()
|
||||
.run_if(|enabled: Res<InspectorEnabled>| enabled.0),
|
||||
)
|
||||
.add_systems(Update, toggle_inspector);
|
||||
.add_systems(Update, (toggle_inspector, toggle_ui_layout_debug));
|
||||
}
|
||||
}
|
||||
|
||||
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" }
|
||||
);
|
||||
if !keys.just_pressed(KeyCode::F1) {
|
||||
return;
|
||||
}
|
||||
|
||||
enabled.0 = !enabled.0;
|
||||
info!(
|
||||
"lobby ui inspector toggled {}",
|
||||
if enabled.0 { "on" } else { "off" }
|
||||
);
|
||||
}
|
||||
|
||||
fn toggle_ui_layout_debug(
|
||||
keys: Res<ButtonInput<KeyCode>>,
|
||||
mut debug_options: ResMut<GlobalUiDebugOptions>,
|
||||
) {
|
||||
if !keys.just_pressed(KeyCode::F2) {
|
||||
return;
|
||||
}
|
||||
|
||||
if debug_options.enabled {
|
||||
debug_options.enabled = false;
|
||||
} else {
|
||||
debug_options.enabled = true;
|
||||
debug_options.outline_border_box = true;
|
||||
debug_options.outline_padding_box = true;
|
||||
debug_options.outline_content_box = true;
|
||||
}
|
||||
info!(
|
||||
"ui layout debug toggled {}",
|
||||
if debug_options.enabled { "on" } else { "off" }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user