Examples can be found at ./crates/bevy-inspector-egui/examples
.
This crate contains
- general purpose machinery for displaying Reflect
values in [reflectinspector],
- a way of associating arbitrary options with fields and enum variants in [inspectoroptions]
- utility functions for displaying bevy resource, entities and assets in [bevy_inspector]
- some drop-in plugins in [quick] to get you started without any code necessary.
The changelog can be found at docs/CHANGELOG.md
.
These plugins can be easily added to your app, but don't allow for customization of the presentation and content.
Displays the world's entities, resources and assets.
```rust use bevy::prelude::*; use bevyinspectoregui::quick::WorldInspectorPlugin;
fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(WorldInspectorPlugin) .run(); } ```
Display a single resource in a window.
```rust use bevy::prelude::; use bevy_inspector_egui::prelude::; use bevyinspectoregui::quick::ResourceInspectorPlugin;
// InspectorOptions
are completely optional
struct Configuration { name: String, #[inspector(min = 0.0, max = 1.0)] option: f32, }
fn main() {
App::new()
.addplugins(DefaultPlugins)
.initresource::ResourceInspectorPlugin
won't initialize the resource
.registertype::
There is also the StateInspectorPlugin
and the AssetInspectorPlugin
.
The [quick] plugins don't allow customization of the egui window or its content, but you can easily build your own UI:
```rust use bevy::prelude::; use bevy_egui::EguiPlugin; use bevy_inspector_egui::prelude::; use std::any::TypeId;
fn main() {
App::new()
.addplugins(DefaultPlugins)
.addplugin(EguiPlugin)
.addplugin(bevyinspectoregui::DefaultInspectorConfigPlugin) // adds default options and InspectorEguiImpl
s
.addsystem(inspector_ui)
.run();
}
fn inspectorui(world: &mut World) {
let eguicontext = world.resourcemut::
egui::Window::new("UI").show(&egui_context, |ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
// equivalent to `WorldInspectorPlugin`
// bevy_inspector_egui::bevy_inspector::ui_for_world(world, ui);
egui::CollapsingHeader::new("Materials").show(ui, |ui| {
bevy_inspector_egui::bevy_inspector::ui_for_assets::<StandardMaterial>(world, ui);
});
ui.heading("Entities");
bevy_inspector_egui::bevy_inspector::ui_for_world_entities(world, ui);
});
});
} ```
Pair this with a crate like egui_dock
and you have your own editor in less than 100 lines: examples/egui_dock.rs
.
Q: How do I change the names of the entities in the world inspector?
A: You can insert the Name
component.
Q: What if I just want to display a single value without passing in the whole &mut World
?
A: You can use reflect_inspector::ui_for_value
. Note that displaying things like Handle<StandardMaterial>
won't be able to display the asset's value.