Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jakobhellermann/bevy-inspector-egui
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.18.0
Choose a base ref
...
head repository: jakobhellermann/bevy-inspector-egui
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.18.1
Choose a head ref
  • 6 commits
  • 7 files changed
  • 1 contributor

Commits on Mar 10, 2023

  1. Copy the full SHA
    acb000a View commit details

Commits on Mar 13, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2aa500c View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4860c65 View commit details
  3. changelog

    jakobhellermann committed Mar 13, 2023
    Copy the full SHA
    62f70a3 View commit details
  4. clippy

    jakobhellermann committed Mar 13, 2023
    Copy the full SHA
    a84a9cc View commit details
  5. v0.18.1

    jakobhellermann committed Mar 13, 2023
    Copy the full SHA
    5fea995 View commit details
2 changes: 1 addition & 1 deletion crates/bevy-inspector-egui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy-inspector-egui"
version = "0.18.0"
version = "0.18.1"
edition = "2021"
repository = "https://github.com/jakobhellermann/bevy-inspector-egui/"
readme = "README.md"
24 changes: 18 additions & 6 deletions crates/bevy-inspector-egui/examples/integrations/egui_dock.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ use bevy_inspector_egui::bevy_inspector::{
use bevy_inspector_egui::DefaultInspectorConfigPlugin;
// use bevy_mod_picking::backends::egui::EguiPointer;
// use bevy_mod_picking::prelude::*;
use bevy_egui::EguiSet;
use bevy_reflect::TypeRegistry;
use bevy_render::camera::{CameraProjection, Viewport};
use bevy_window::PrimaryWindow;
@@ -24,9 +25,18 @@ fn main() {
.add_plugin(bevy_egui::EguiPlugin)
// .add_plugins(bevy_mod_picking::plugins::DefaultPickingPlugins)
.insert_resource(UiState::new())
.add_system(show_ui_system.in_base_set(CoreSet::PreUpdate))
.add_startup_system(setup)
.add_system(set_camera_viewport)
.add_system(
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)
@@ -74,10 +84,11 @@ fn handle_pick_events(
struct MainCamera;

fn show_ui_system(world: &mut World) {
let mut egui_context = world
let Ok(egui_context) = world
.query_filtered::<&mut EguiContext, With<PrimaryWindow>>()
.single(world)
.clone();
.get_single(world) else { return };
let mut egui_context = egui_context.clone();

world.resource_scope::<UiState, _>(|world, mut ui_state| {
ui_state.ui(world, egui_context.get_mut())
});
@@ -92,7 +103,8 @@ fn set_camera_viewport(
) {
let mut cam = cameras.single_mut();

let window = primary_window.single();
let Ok(window) = primary_window.get_single() else { return };

let scale_factor = window.scale_factor() * egui_settings.scale_factor;

let viewport_pos = ui_state.viewport_rect.left_top().to_vec2() * scale_factor as f32;
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ pub fn entity_ui(

let entity_name =
crate::utils::guess_entity_name::guess_entity_name_restricted(world, entity);
egui::CollapsingHeader::new(&entity_name)
egui::CollapsingHeader::new(entity_name)
.id_source(id)
.show(ui, |ui| {
let _queue = CommandQueue::default();
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use crate::reflect_inspector::InspectorUi;

macro_rules! vec_ui_many {
($name_many:ident $ty:ty>$elem_ty:ty: $count:literal $($component:ident)*) => {
pub fn $name_many<'a>(
pub fn $name_many(
ui: &mut egui::Ui,
_: &dyn Any,
id: egui::Id,
36 changes: 19 additions & 17 deletions crates/bevy-inspector-egui/src/quick.rs
Original file line number Diff line number Diff line change
@@ -23,28 +23,18 @@ const DEFAULT_SIZE: (f32, f32) = (320., 160.);

/// Plugin displaying a egui window with an entity list, resources and assets
///
/// You can use [`WorldInspectorPlugin::run_if`] to control when the window is shown, for example
/// in combination with `input_toggle_active`.
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_inspector_egui::prelude::*;
/// use bevy_inspector_egui::quick::ResourceInspectorPlugin;
///
/// // `InspectorOptions` are completely optional
/// #[derive(Reflect, Resource, Default, InspectorOptions)]
/// #[reflect(Resource, InspectorOptions)]
/// struct Configuration {
/// name: String,
/// #[inspector(min = 0.0, max = 1.0)]
/// option: f32,
/// }
/// use bevy_inspector_egui::quick::WorldInspectorPlugin;
///
/// fn main() {
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .init_resource::<Configuration>() // `ResourceInspectorPlugin` won't initialize the resource
/// .register_type::<Configuration>() // you need to register your type to display it
/// .add_plugin(ResourceInspectorPlugin::<Configuration>::default())
/// // also works with built-in resources, as long as they implement `Reflect`
/// .add_plugin(ResourceInspectorPlugin::<Time>::default())
/// .add_plugin(WorldInspectorPlugin::new())
/// .run();
/// }
/// ```
@@ -102,6 +92,9 @@ fn world_inspector_ui(world: &mut World) {
/// Plugin displaying an egui window for a single resource.
/// Remember to insert the resource and call [`App::register_type`](bevy_app::App::register_type).
///
/// You can use [`ResourceInspectorPlugin::run_if`] to control when the window is shown, for example
/// in combination with `input_toggle_active`.
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_inspector_egui::prelude::*;
@@ -191,6 +184,9 @@ fn inspector_ui<T: Resource + Reflect>(world: &mut World) {
/// Plugin displaying an egui window for an app state.
/// Remember to call [`App::add_state`](bevy_app::App::add_state) .
///
/// You can use [`StateInspectorPlugin::run_if`] to control when the window is shown, for example
/// in combination with `input_toggle_active`.
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_inspector_egui::quick::StateInspectorPlugin;
@@ -199,14 +195,15 @@ fn inspector_ui<T: Resource + Reflect>(world: &mut World) {
/// App::new()
/// .add_plugins(DefaultPlugins)
/// .insert_resource(ClearColor(Color::BLACK))
/// .add_state(AppState::A)
/// .add_state::<AppState>()
/// .register_type::<AppState>()
/// .add_plugin(StateInspectorPlugin::<AppState>::default())
/// .run();
/// }
///
/// #[derive(Debug, Clone, Eq, PartialEq, Hash, Reflect)]
/// #[derive(Default, States, Debug, Clone, Eq, PartialEq, Hash, Reflect)]
/// enum AppState {
/// #[default]
/// A,
/// B,
/// C,
@@ -274,6 +271,10 @@ fn state_ui<T: States + Reflect>(world: &mut World) {

/// Plugin displaying an egui window for all assets of type `A`.
/// Remember to call [`App::register_asset_reflect`](bevy_asset::AddAsset::register_asset_reflect).
///
/// You can use [`AssetInspectorPlugin::run_if`] to control when the window is shown, for example
/// in combination with `input_toggle_active`.
///
/// ```no_run
/// use bevy::prelude::*;
/// use bevy_inspector_egui::quick::AssetInspectorPlugin;
@@ -453,6 +454,7 @@ impl System for BoxedConditionHelper {
}

unsafe fn run_unsafe(&mut self, input: Self::In, world: &World) -> Self::Out {
// SAFETY: same as this method
unsafe { self.0.run_unsafe(input, world) }
}

10 changes: 9 additions & 1 deletion crates/bevy-inspector-egui/src/utils.rs
Original file line number Diff line number Diff line change
@@ -40,7 +40,15 @@ pub mod guess_entity_name {
entity: Entity,
) -> String {
match world.world().get_entity(entity) {
Some(cell) => guess_entity_name_inner(world.world(), entity, cell.archetype()),
Some(cell) => {
if world.allows_access_to_component((entity, std::any::TypeId::of::<Name>())) {
// SAFETY: we have access and don't keep reference
if let Some(name) = unsafe { cell.get::<Name>() } {
return name.as_str().to_string();
}
}
guess_entity_name_inner(world.world(), entity, cell.archetype())
}
None => format!("Entity {} (inexistent)", entity.index()),
}
}
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Version 0.18.1
- fix nested entity name not being displayed
- fix `WorldInspectorPlugin` docs
- fix `egui_dock` system order

## Version 0.18.0
- update to `bevy` 0.10
- add `run_if` to `quick::*` plugins