bevy-inspector-egui
V2 - call for feedback
#85
Replies: 3 comments 9 replies
-
Actual Use CasesOr what do you want from the inspector?
fn show_inspector_system(world: &mut World);
egui::Window::new("Inspector").show(|ui| {
egui.collapsing("Settings", |ui| {
bevy_inspector_egui::ui_for_resource::<GameSettings>(world);
});
egui.collapsing("Entities", |ui| {
bevy_inspector_egui::ui_for_entities(world);
});
}
} Also how powerful should the default world inspector be? Do you want to search for entities? For components? Same question for potentially displaying resources. Any other feature requests can go here too. |
Beta Was this translation helpful? Give feedback.
-
Ergonomics of the
|
Beta Was this translation helpful? Give feedback.
-
Reusability outside of bevyThe core Would anyone want to reuse the The |
Beta Was this translation helpful? Give feedback.
-
I've been rewriting
bevy-inspector-egui
to work just onReflect
and obsolete theInspectable
trait, while also improving a bunch of other things, and wanted to get feedback on some design decisions.First, some background:
Background (optional)
When I first started the inspector, it was very focused around the
Inspectable
trait, which you can derive to get afn ui(&mut self, ui: &mut egui::Ui, ...)
that you can execute to display the UI.The way you could use this was with the
InspectorPlugin<T: Inspectable>
which would insertT
as a resource that you could then you.Later, someone contributed a "world inspector", which let you just display all entities together without having to create your inspectable resource. For me this world inspector became the only thing I used because of the simplicity of just adding
WorldInspectorPlugin
and being done with it, and for the flexibility of inspecting every entity and component there is in the world.For the world inspector to work I added a
InspectableRegistry
resource, which is aHashMap<TypeId, fn(&mut ?, ui: &mut egui::Ui, ...)
and had to register every type that derived or implementedInspectable
on it:app.register_inspectable::<Type>()
. This was particularly annoying because everyone that defined their custom components also had to do it in order to get their type displayed in the world inspector.Meanwhile,
bevy_reflect
had been gaining functionality and usage, so I hacked onReflect
support intobevy-inspector-egui
. If you derived (and registered)Reflect
for a type, that type would show up in the world inspector, but it was always a second class citizen, you couldn't deriveInspectable
with justReflect
fields, and theReflect
ed component could not define attributes likemin = 0.0, max = 1.0
.The rewrite
This is where the rewrite comes in, instead of focusing on the
Inspectable
trait which 1. enables walking the type hierarchy and 2. can render UI I realised that I could do the same by just usingReflect
to inspect the "structure/shape" of a type and write afunction that displays the UI.
That way, users of the library don't have to
#[derive(Inspectable)]
anymore, the can just use#[derive(Reflect)]
which is useful for other things as well.On top of this, I also reimplemented the world inspector, which now looks like this:
It would be very easy to build your own specific UI as well with these building blocks.
Options
This still leaves open the question of how to represent
#[inspectable(min = 0.0, max = 1.0)]
options.The way I settled this is by introducing a type,
InspectorOptions
, which can represent thesefield -> arbitrary options
and can be derived separately:The Questions
Before polishing this and releasing this (hopefully with bevy 0.9) I'd like to get some feedback on a few design decisions and also look at what people actually want to use this for.
I'll open separate comments on the discussion for each question.
InspectorOptions
deriveFeel free to open any other comments below.
Beta Was this translation helpful? Give feedback.
All reactions