• Stars
    star
    1,125
  • Rank 41,364 (Top 0.9 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Inspector plugin for the bevy game engine

bevy-inspector-egui

Examples can be found at ./crates/bevy-inspector-egui/examples.

This crate contains

  • general purpose machinery for displaying Reflect values in reflect_inspector,
  • a way of associating arbitrary options with fields and enum variants in inspector_options
  • 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.

Use case 1: Quick plugins

These plugins can be easily added to your app, but don't allow for customization of the presentation and content.

WorldInspectorPlugin

Displays the world's entities, resources and assets.

image of the world inspector

use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(WorldInspectorPlugin::new())
        .run();
}

ResourceInspectorPlugin

Display a single resource in a window.

image of the resource inspector

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,
}

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 are `Reflect`
        .add_plugin(ResourceInspectorPlugin::<Time>::default())
        .run();
}

There is also the StateInspectorPlugin and the AssetInspectorPlugin.

Use case 2: Manual UI

The quick plugins don't allow customization of the egui window or its content, but you can easily build your own UI:

use bevy::prelude::*;
use bevy_egui::EguiPlugin;
use bevy_inspector_egui::prelude::*;
use std::any::TypeId;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(EguiPlugin)
        .add_plugin(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s
        .add_system(inspector_ui)
        .run();
}

fn inspector_ui(world: &mut World) {
    let egui_context = world.resource_mut::<bevy_egui::EguiContext>().ctx_mut().clone();

    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. image of the egui_dock example

Cargo features

  • highlight_changes - highlight changed values every frame. Ideally this should be runtime-configurable, but it was implemented like this as a stopgap solution. If you'd like to configure this at runtime, please open an issue to let me know it's more of a priority.
  • bevy_pbr (default): register default options for bevy_pbr types. You should disable this if you don't use bevy_pbr to reduce the dependency footprint.

FAQ

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.

Bevy support table

Bevy support table

bevy bevy-inspector-egui
0.10 0.18
0.9 0.14-0.17
0.8 0.12-0.13
0.7 0.10-0.11
0.6 0.9
0.6 0.8
0.6 0.7
0.5 0.5-0.6
0.5 0.4
0.4 0.1-0.3

More Repositories

1

bevy_editor_pls

In-App editor tools for bevy applications
Rust
711
star
2

bevy_mod_debugdump

Rust
247
star
3

wasm-server-runner

cargo run for the browser
Rust
138
star
4

bevycheck

Rust
84
star
5

bevy_mod_js_scripting

Rust
80
star
6

piechart

a rust crate for drawing fancy pie charts in the terminal
Rust
38
star
7

rupnp

Rust library for the universal plug and play protocol.
Rust
35
star
8

cargo-watt

cargo subcommand for building proc-macro crates with web assembly
Rust
34
star
9

axum_openapi

Rust
31
star
10

sonor

Sonos library for rust
Rust
31
star
11

bevy-contrib-inspector

bevy plugin for starting a webserver to visually edit bevy resources
Rust
21
star
12

bevy_ecs_dynamic

Utilites for working with `bevy_ecs` when not all types are known at compile time
Rust
19
star
13

ssdp-client

An asynchronous Rust library for discovering, notifying and subscribing to devices and services on a network.
Rust
11
star
14

watt-contrib

Rust
8
star
15

ezoauth

Easy to use OAuth2 client for rust
Rust
7
star
16

deno-progressbar

a terminal progressbar for deno
TypeScript
5
star
17

pretty-type-name

Rust
4
star
18

bevy_reflect_ts_type_export

TypeScript
4
star
19

tts-urls

Generate URLs from TTS services, a rust crate
Rust
4
star
20

bevy-asset-distill

Rust
4
star
21

bevy-unofficial-playground-experiments

πŸ‘€
Rust
4
star
22

Atlas

Render and visualize paths for Celeste TASes
Rust
3
star
23

bevy_shadertoy

Rust
2
star
24

bevy_reflect_fns

Experimentation for reflecting methods using bevy_reflect, to be upstreamed later
Rust
2
star
25

dotfiles

Shell
1
star
26

websocket-async-io

Rust
1
star
27

mc-mod-muffle

A minecraft mod for the fabric modloader which adds a Sound Muffler
Java
1
star
28

trout

TSP solver for routing celeste lobbies while TASing
Rust
1
star
29

CelesteSavefileMerger

Savefile Merger for Celeste
C#
1
star
30

bevy-pipelined-testing

Rust
1
star
31

jakobhellermann.github.io

HTML
1
star
32

celestetools

Rust
1
star