upgrade to bevy 0.20

This commit is contained in:
2026-10-20 23:59:48 -05:00
parent 4607f12756
commit 25557d85ce
7 changed files with 1626 additions and 1591 deletions
+39 -10
View File
@@ -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" }
);
}