From bfcd9276171e483cfd6c4bf1e91ec2bc77cc40c6 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Sun, 18 Jun 2023 23:06:11 +0200 Subject: [PATCH 1/2] update bevy to main --- README.md | 2 +- crates/bevy-inspector-egui-derive/Cargo.toml | 6 +- crates/bevy-inspector-egui/Cargo.toml | 47 +++++++++----- .../examples/basic/inspector_options.rs | 4 +- .../basic/resource_inspector_manual.rs | 4 +- .../examples/integrations/egui_dock.rs | 18 ++--- .../examples/integrations/side_panel.rs | 9 ++- .../examples/quick/asset_inspector.rs | 2 +- .../examples/quick/filter_query_inspector.rs | 6 +- .../examples/quick/resource_inspector.rs | 2 +- .../examples/quick/state_inspector.rs | 8 +-- .../examples/quick/world_inspector.rs | 6 +- .../examples/quick/world_inspector_assets.rs | 2 +- .../src/bevy_inspector/mod.rs | 2 +- crates/bevy-inspector-egui/src/lib.rs | 2 +- crates/bevy-inspector-egui/src/quick.rs | 65 ++++++++++--------- .../src/reflect_inspector/mod.rs | 16 ++--- 17 files changed, 108 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index a3a69bc8..3f5506ba 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ fn main() { .add_plugins(DefaultPlugins) .add_plugin(EguiPlugin) .add_plugin(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s - .add_system(inspector_ui) + .add_systems(Update, inspector_ui) .run(); } diff --git a/crates/bevy-inspector-egui-derive/Cargo.toml b/crates/bevy-inspector-egui-derive/Cargo.toml index fac2f534..0b0dfd6a 100644 --- a/crates/bevy-inspector-egui-derive/Cargo.toml +++ b/crates/bevy-inspector-egui-derive/Cargo.toml @@ -17,7 +17,7 @@ quote = "1.0" proc-macro2 = "1.0" [dev-dependencies] -bevy_ecs = { version = "0.10", default-features = false } -bevy_math = { version = "0.10", default-features = false } -bevy_reflect = { version = "0.10", default-features = false } +bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false } +bevy_math = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false } +bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false } bevy-inspector-egui = { path = "../bevy-inspector-egui" } diff --git a/crates/bevy-inspector-egui/Cargo.toml b/crates/bevy-inspector-egui/Cargo.toml index 52090699..89599459 100644 --- a/crates/bevy-inspector-egui/Cargo.toml +++ b/crates/bevy-inspector-egui/Cargo.toml @@ -8,7 +8,12 @@ license = "MIT OR Apache-2.0" description = "Inspector plugin for the bevy game engine" documentation = "https://docs.rs/bevy-inspector-egui" keywords = ["bevy", "inspector", "egui", "editor", "reflect"] -categories = ["game-development", "gui", "visualization", "development-tools::procedural-macro-helpers"] +categories = [ + "game-development", + "gui", + "visualization", + "development-tools::procedural-macro-helpers", +] [features] default = ["bevy_pbr"] @@ -16,23 +21,23 @@ highlight_changes = [] [dependencies] bevy-inspector-egui-derive = { version = "0.18.0", path = "../bevy-inspector-egui-derive" } -bevy_app = { version = "0.10" } -bevy_asset = { version = "0.10" } -bevy_core = { version = "0.10" } -bevy_ecs = { version = "0.10" } -bevy_hierarchy = { version = "0.10" } -bevy_log = { version = "0.10" } -bevy_math = { version = "0.10" } -bevy_reflect = { version = "0.10" } -bevy_utils = { version = "0.10" } -bevy_window = { version = "0.10" } - -bevy_core_pipeline = { version = "0.10" } -bevy_pbr = { version = "0.10", optional = true } -bevy_render = { version = "0.10" } +bevy_app = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_asset = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_core = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_hierarchy = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_log = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_math = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_utils = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_window = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } + +bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } +bevy_pbr = { git = "https://github.com/bevyengine/bevy.git", branch = "main", optional = true } +bevy_render = { git = "https://github.com/bevyengine/bevy.git", branch = "main" } egui = "0.21" -bevy_egui = "0.20" +bevy_egui = { git = "https://github.com/Vrixyz/bevy_egui.git", branch = "bevy-main" } image = { version = "0.24", default-features = false } once_cell = "1.16" @@ -40,7 +45,15 @@ pretty-type-name = "1.0" smallvec = "1.10" [dev-dependencies] -bevy = { version = "0.10", default-features = false, features = ["x11", "bevy_winit", "bevy_pbr", "bevy_sprite", "bevy_core_pipeline", "animation", "png"] } +bevy = { git = "https://github.com/bevyengine/bevy.git", branch = "main", default-features = false, features = [ + "x11", + "bevy_winit", + "bevy_pbr", + "bevy_sprite", + "bevy_core_pipeline", + "animation", + "png", +] } egui_dock = "0.4" egui-gizmo = "0.10" # bevy_mod_picking = { git = "https://github.com/aevyrie/bevy_mod_picking", rev = "554649a951689dce66d0d759839b326874e8826f", default-features = false, features = ["backend_raycast", "backend_egui", "backend_sprite"] } diff --git a/crates/bevy-inspector-egui/examples/basic/inspector_options.rs b/crates/bevy-inspector-egui/examples/basic/inspector_options.rs index a51fa30b..7f8f7f7f 100644 --- a/crates/bevy-inspector-egui/examples/basic/inspector_options.rs +++ b/crates/bevy-inspector-egui/examples/basic/inspector_options.rs @@ -61,8 +61,8 @@ fn main() { .register_type::() .register_type::() .register_type::() - .add_startup_system(setup) - .add_system(ui_example) + .add_systems(Startup, setup) + .add_systems(Update, ui_example) .run(); } diff --git a/crates/bevy-inspector-egui/examples/basic/resource_inspector_manual.rs b/crates/bevy-inspector-egui/examples/basic/resource_inspector_manual.rs index 2d983390..f415ec0c 100644 --- a/crates/bevy-inspector-egui/examples/basic/resource_inspector_manual.rs +++ b/crates/bevy-inspector-egui/examples/basic/resource_inspector_manual.rs @@ -22,9 +22,9 @@ fn main() { // insert and register resource .init_resource::() .register_type::() - .add_startup_system(setup) + .add_systems(Startup, setup) // add the system showing the UI - .add_system(inspector_ui) + .add_systems(Update, inspector_ui) .run(); } diff --git a/crates/bevy-inspector-egui/examples/integrations/egui_dock.rs b/crates/bevy-inspector-egui/examples/integrations/egui_dock.rs index c770da01..b0a21042 100644 --- a/crates/bevy-inspector-egui/examples/integrations/egui_dock.rs +++ b/crates/bevy-inspector-egui/examples/integrations/egui_dock.rs @@ -25,21 +25,17 @@ fn main() { .add_plugin(bevy_egui::EguiPlugin) // .add_plugins(bevy_mod_picking::plugins::DefaultPickingPlugins) .insert_resource(UiState::new()) - .add_startup_system(setup) - .add_system( + .add_systems(Startup, setup) + .add_systems( + PostUpdate, show_ui_system - .in_base_set(CoreSet::PostUpdate) .before(EguiSet::ProcessOutput) .before(bevy::transform::TransformSystem::TransformPropagate), ) - .add_system( - set_camera_viewport - .in_base_set(CoreSet::PostUpdate) - .after(show_ui_system), - ) - .add_system(set_gizmo_mode) - // .add_system(auto_add_raycast_target) - // .add_system(handle_pick_events) + .add_systems(PostUpdate, set_camera_viewport.after(show_ui_system)) + .add_systems(Update, set_gizmo_mode) + // .add_systems(Update, auto_add_raycast_target) + // .add_systems(Update, handle_pick_events) .register_type::>>() .register_type::() .run(); diff --git a/crates/bevy-inspector-egui/examples/integrations/side_panel.rs b/crates/bevy-inspector-egui/examples/integrations/side_panel.rs index 4ad411f9..b0558164 100644 --- a/crates/bevy-inspector-egui/examples/integrations/side_panel.rs +++ b/crates/bevy-inspector-egui/examples/integrations/side_panel.rs @@ -10,9 +10,12 @@ fn main() { .add_plugins(DefaultPlugins) .add_plugin(EguiPlugin) .add_plugin(DefaultInspectorConfigPlugin) - .add_startup_system(setup) - .add_system(rotator_system) - .add_system(inspector_ui.run_if(input_toggle_active(true, KeyCode::Escape))) + .add_systems(Startup, setup) + .add_systems(Update, rotator_system) + .add_systems( + Update, + inspector_ui.run_if(input_toggle_active(true, KeyCode::Escape)), + ) .run(); } diff --git a/crates/bevy-inspector-egui/examples/quick/asset_inspector.rs b/crates/bevy-inspector-egui/examples/quick/asset_inspector.rs index 766cd3a1..dfe85da7 100644 --- a/crates/bevy-inspector-egui/examples/quick/asset_inspector.rs +++ b/crates/bevy-inspector-egui/examples/quick/asset_inspector.rs @@ -5,7 +5,7 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugin(AssetInspectorPlugin::::default()) - .add_startup_system(setup) + .add_systems(Startup, setup) .run(); } diff --git a/crates/bevy-inspector-egui/examples/quick/filter_query_inspector.rs b/crates/bevy-inspector-egui/examples/quick/filter_query_inspector.rs index 35f42912..f9ae5498 100644 --- a/crates/bevy-inspector-egui/examples/quick/filter_query_inspector.rs +++ b/crates/bevy-inspector-egui/examples/quick/filter_query_inspector.rs @@ -5,7 +5,7 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugin(FilterQueryInspectorPlugin::>::default()) - .add_startup_system(setup) + .add_systems(Startup, setup) .run(); } @@ -29,7 +29,7 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { + /*commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, shadows_enabled: true, @@ -37,7 +37,7 @@ fn setup( }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..default() - }); + });*/ // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/crates/bevy-inspector-egui/examples/quick/resource_inspector.rs b/crates/bevy-inspector-egui/examples/quick/resource_inspector.rs index 35076e91..cf9c61b5 100644 --- a/crates/bevy-inspector-egui/examples/quick/resource_inspector.rs +++ b/crates/bevy-inspector-egui/examples/quick/resource_inspector.rs @@ -20,7 +20,7 @@ fn main() { ) .init_resource::() .register_type::() - .add_startup_system(setup) + .add_systems(Startup, setup) .run(); } diff --git a/crates/bevy-inspector-egui/examples/quick/state_inspector.rs b/crates/bevy-inspector-egui/examples/quick/state_inspector.rs index 40fd337e..c19e4648 100644 --- a/crates/bevy-inspector-egui/examples/quick/state_inspector.rs +++ b/crates/bevy-inspector-egui/examples/quick/state_inspector.rs @@ -8,10 +8,10 @@ fn main() { .add_state::() .register_type::() .add_plugin(StateInspectorPlugin::::default()) - .add_startup_system(setup) - .add_system(set_color::<158, 228, 147>.in_schedule(OnEnter(AppState::A))) - .add_system(set_color::<172, 200, 192>.in_schedule(OnEnter(AppState::B))) - .add_system(set_color::<194, 148, 138>.in_schedule(OnEnter(AppState::C))) + .add_systems(Startup, setup) + .add_systems(OnEnter(AppState::A), set_color::<158, 228, 147>) + .add_systems(OnEnter(AppState::B), set_color::<172, 200, 192>) + .add_systems(OnEnter(AppState::C), set_color::<194, 148, 138>) .run(); } diff --git a/crates/bevy-inspector-egui/examples/quick/world_inspector.rs b/crates/bevy-inspector-egui/examples/quick/world_inspector.rs index 13453d99..1f849268 100644 --- a/crates/bevy-inspector-egui/examples/quick/world_inspector.rs +++ b/crates/bevy-inspector-egui/examples/quick/world_inspector.rs @@ -8,7 +8,7 @@ fn main() { .add_plugin( WorldInspectorPlugin::default().run_if(input_toggle_active(true, KeyCode::Escape)), ) - .add_startup_system(setup) + .add_systems(Startup, setup) .run(); } @@ -32,7 +32,7 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { + /*commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, shadows_enabled: true, @@ -40,7 +40,7 @@ fn setup( }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..default() - }); + });*/ // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/crates/bevy-inspector-egui/examples/quick/world_inspector_assets.rs b/crates/bevy-inspector-egui/examples/quick/world_inspector_assets.rs index 989417a1..1e764474 100644 --- a/crates/bevy-inspector-egui/examples/quick/world_inspector_assets.rs +++ b/crates/bevy-inspector-egui/examples/quick/world_inspector_assets.rs @@ -7,7 +7,7 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugin(WorldInspectorPlugin::default()) - .add_startup_system(setup) + .add_systems(Startup, setup) .run(); } diff --git a/crates/bevy-inspector-egui/src/bevy_inspector/mod.rs b/crates/bevy-inspector-egui/src/bevy_inspector/mod.rs index 16eeff62..76ec6e55 100644 --- a/crates/bevy-inspector-egui/src/bevy_inspector/mod.rs +++ b/crates/bevy-inspector-egui/src/bevy_inspector/mod.rs @@ -205,7 +205,7 @@ pub fn ui_for_state(world: &mut World, ui: &mut egui::Ui) { }; let mut env = InspectorUi::for_bevy(&type_registry, &mut cx); - let mut current = state.0.clone(); + let mut current = state.clone(); let changed = env.ui_for_reflect(&mut current, ui); if changed { diff --git a/crates/bevy-inspector-egui/src/lib.rs b/crates/bevy-inspector-egui/src/lib.rs index 9f8a830f..8b8d1d1f 100644 --- a/crates/bevy-inspector-egui/src/lib.rs +++ b/crates/bevy-inspector-egui/src/lib.rs @@ -87,7 +87,7 @@ //! .add_plugins(DefaultPlugins) //! .add_plugin(EguiPlugin) //! .add_plugin(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s -//! .add_system(inspector_ui) +//! .add_systems(Update, inspector_ui) //! .run(); //! } //! diff --git a/crates/bevy-inspector-egui/src/quick.rs b/crates/bevy-inspector-egui/src/quick.rs index 40ea5273..f782cf52 100644 --- a/crates/bevy-inspector-egui/src/quick.rs +++ b/crates/bevy-inspector-egui/src/quick.rs @@ -8,10 +8,13 @@ use std::{marker::PhantomData, sync::Mutex}; -use bevy_app::Plugin; +use bevy_app::{Plugin, Update}; use bevy_asset::Asset; use bevy_ecs::prelude::*; -use bevy_ecs::{query::ReadOnlyWorldQuery, schedule::BoxedCondition, system::ReadOnlySystem}; +use bevy_ecs::{ + query::ReadOnlyWorldQuery, schedule::BoxedCondition, schedule::IntoSystemSetConfig, + system::ReadOnlySystem, +}; use bevy_egui::{EguiContext, EguiPlugin}; use bevy_reflect::Reflect; use bevy_window::PrimaryWindow; @@ -66,11 +69,11 @@ impl Plugin for WorldInspectorPlugin { } let condition = self.condition.lock().unwrap().take(); - let mut system = world_inspector_ui.into_config(); + let mut system = world_inspector_ui.into_configs(); if let Some(condition) = condition { system = system.run_if(BoxedConditionHelper(condition)); } - app.add_system(system); + app.add_systems(Update, system); } } @@ -81,7 +84,7 @@ fn world_inspector_ui(world: &mut World) { let Ok(egui_context) = egui_context else {return;}; let mut egui_context = egui_context.clone(); - + egui::Window::new("World Inspector") .default_size(DEFAULT_SIZE) .show(egui_context.get_mut(), |ui| { @@ -160,11 +163,11 @@ impl Plugin for ResourceInspectorPlugin { } let condition = self.condition.lock().unwrap().take(); - let mut system = inspector_ui::.into_config(); + let mut system = inspector_ui::.into_configs(); if let Some(condition) = condition { system = system.run_if(BoxedConditionHelper(condition)); } - app.add_system(system); + app.add_systems(Update, system); } } @@ -251,11 +254,11 @@ impl Plugin for StateInspectorPlugin { } let condition = self.condition.lock().unwrap().take(); - let mut system = state_ui::.into_config(); + let mut system = state_ui::.into_configs(); if let Some(condition) = condition { system = system.run_if(BoxedConditionHelper(condition)); } - app.add_system(system); + app.add_systems(Update, system); } } @@ -331,11 +334,11 @@ impl Plugin for AssetInspectorPlugin { } let condition = self.condition.lock().unwrap().take(); - let mut system = asset_inspector_ui::.into_config(); + let mut system = asset_inspector_ui::.into_configs(); if let Some(condition) = condition { system = system.run_if(BoxedConditionHelper(condition)); } - app.add_system(system); + app.add_systems(Update, system); } } @@ -346,7 +349,7 @@ fn asset_inspector_ui(world: &mut World) { let Ok(egui_context) = egui_context else {return;}; let mut egui_context = egui_context.clone(); - + egui::Window::new(pretty_type_name::()) .default_size(DEFAULT_SIZE) .show(egui_context.get_mut(), |ui| { @@ -408,12 +411,13 @@ where app.add_plugin(EguiPlugin); } - let condition = self.condition.lock().unwrap().take(); - let mut system = IntoSystemConfig::into_config(entity_query_ui::); + let condition: Option>> = + self.condition.lock().unwrap().take(); + let mut system = entity_query_ui::.into_configs(); if let Some(condition) = condition { system = system.run_if(BoxedConditionHelper(condition)); } - app.add_system(system); + app.add_systems(Update, system); } } @@ -424,7 +428,7 @@ fn entity_query_ui(world: &mut World) { let Ok(egui_context) = egui_context else {return;}; let mut egui_context = egui_context.clone(); - + egui::Window::new(pretty_type_name::()) .default_size(DEFAULT_SIZE) .show(egui_context.get_mut(), |ui| { @@ -467,33 +471,36 @@ impl System for BoxedConditionHelper { fn is_exclusive(&self) -> bool { self.0.is_exclusive() } - - unsafe fn run_unsafe(&mut self, input: Self::In, world: &World) -> Self::Out { + unsafe fn run_unsafe( + &mut self, + input: Self::In, + world: bevy_ecs::world::unsafe_world_cell::UnsafeWorldCell, + ) -> Self::Out { // SAFETY: same as this method unsafe { self.0.run_unsafe(input, world) } } - fn apply_buffers(&mut self, world: &mut World) { - self.0.apply_buffers(world) + fn apply_deferred(&mut self, world: &mut World) { + self.0.apply_deferred(world) } fn initialize(&mut self, _world: &mut World) { self.0.initialize(_world) } - fn update_archetype_component_access(&mut self, world: &World) { + fn update_archetype_component_access( + &mut self, + world: bevy_ecs::world::unsafe_world_cell::UnsafeWorldCell, + ) { self.0.update_archetype_component_access(world) } - - fn check_change_tick(&mut self, change_tick: u32) { + fn check_change_tick(&mut self, change_tick: bevy_ecs::component::Tick) { self.0.check_change_tick(change_tick) } - - fn get_last_change_tick(&self) -> u32 { - self.0.get_last_change_tick() + fn get_last_run(&self) -> bevy_ecs::component::Tick { + self.0.get_last_run() } - - fn set_last_change_tick(&mut self, last_change_tick: u32) { - self.0.set_last_change_tick(last_change_tick) + fn set_last_run(&mut self, last_run: bevy_ecs::component::Tick) { + self.0.set_last_run(last_run) } } diff --git a/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs b/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs index 33402469..54c3e629 100644 --- a/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs +++ b/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs @@ -366,13 +366,6 @@ impl InspectorUi<'_, '_> { } TypeInfo::Enum(info) => self.ui_for_enum_many(info, ui, id, options, values, projector), TypeInfo::Value(info) => self.ui_for_value_many(info, ui, id, options), - TypeInfo::Dynamic(_) => { - errors::no_multiedit( - ui, - &pretty_type_name::pretty_type_name_str(info.type_name()), - ); - false - } } } } @@ -654,7 +647,7 @@ impl InspectorUi<'_, '_> { } } - let TypeInfo::List(info) = list.get_type_info() else { return }; + let Some(TypeInfo::List(info)) = list.get_represented_type_info() else { return }; let error_id = id.with("error"); ui.vertical_centered_justified(|ui| { @@ -894,7 +887,10 @@ impl InspectorUi<'_, '_> { id: egui::Id, options: &dyn Any, ) -> bool { - let type_info = value.get_type_info(); + let Some(type_info) = value.get_represented_type_info() else { + ui.label("Unrepresentable"); + return false; + }; let type_info = match type_info { TypeInfo::Enum(info) => info, _ => unreachable!("invalid reflect impl: type info mismatch"), @@ -1256,7 +1252,7 @@ impl<'a, 'c> InspectorUi<'a, 'c> { } VariantInfo::Unit(_) => DynamicVariant::Unit, }; - let dynamic_enum = DynamicEnum::new(enum_type_name, variant.name(), dynamic_variant); + let dynamic_enum = DynamicEnum::new(variant.name(), dynamic_variant); Ok(dynamic_enum) } } From 7e7726ddb16bba21d10d58457e713b70590bfaad Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Sun, 18 Jun 2023 23:59:35 +0200 Subject: [PATCH 2/2] fix bright pink material --- crates/bevy-inspector-egui/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/bevy-inspector-egui/Cargo.toml b/crates/bevy-inspector-egui/Cargo.toml index 89599459..f9e51f0f 100644 --- a/crates/bevy-inspector-egui/Cargo.toml +++ b/crates/bevy-inspector-egui/Cargo.toml @@ -53,6 +53,9 @@ bevy = { git = "https://github.com/bevyengine/bevy.git", branch = "main", defaul "bevy_core_pipeline", "animation", "png", + "zstd", + "tonemapping_luts", + "ktx2", ] } egui_dock = "0.4" egui-gizmo = "0.10"