Inspector plugin for the bevy game engine

Overview

bevy-inspector-egui


This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where you can visually edit the values of your struct live.

Your struct will then be available to you as a bevy resource.

demonstration with a running bevy app

Example

use bevy_inspector_egui::Inspectable;

#[derive(Inspectable, Default)]
struct Data {
    should_render: bool,
    text: String,
    #[inspectable(min = 42.0, max = 100.0)]
    size: f32,
}

Add the InspectorPlugin to your App.

use bevy_inspector_egui::InspectorPlugin;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(InspectorPlugin::<Data>::new())
        .add_system(your_system.system())
        .run();
}

// fn your_system(data: Res<Data>) { /* */ }

Bevy support table

bevy bevy-inspector-egui
0.4 0.1-0.3
Comments
  • Rapier2D components

    Rapier2D components

    Thanks for the great crate. I am currently facing an issue while trying to inspect rapier2D-specific components such as RigidBodyPosition or ColliderType. The message Inspectable has not been defined for this component is shown, even though:

    • I am compiling with the rapier2d feature set:
    bevy-inspector-egui = { version="0.6.1", features=["rapier2d"]}
    
    • I am using the WorldInspectorPlugin
    app.add_plugin(WorldInspectorPlugin::new());
    

    Is there anything I am missing in order to get this going?

    opened by no-materials 13
  • Inspecting without mutating

    Inspecting without mutating

    Hi!

    I wanted to suggest adding an immutable variant of Inspectable trait, which would allow only viewing values (or probably just another trait function).

    There are some resources, particular components or their fields in my game, that I would like to be able to view, but prohibit myself from editing. Is it something that you could consider supporting?

    Btw, this is a really awesome crate, thanks for developing it. :)

    opened by mvlabat 11
  • Option<T: Reflect> claims to be unregistered

    Option claims to be unregistered

    Issue

    I have a type Spawner which derives Reflect. But when used as a field in a component, the world inspector complains it's not registered:

    image

    I even tried to explicitly register the Option<T> itself, without much luck:

    app.register_type::<ParticleEffect>();
    app.register_type::<Spawner>();
    app.register_type::<Option<Spawner>>();
    

    Context

    The component ParticleEffect is defined here:

    https://github.com/djeedai/bevy_hanabi/blob/451bd340333c2b02c4bf4b073a09834d4f242654/src/lib.rs#L237-L256

    And the Spawner is here:

    https://github.com/djeedai/bevy_hanabi/blob/451bd340333c2b02c4bf4b073a09834d4f242654/src/spawn.rs#L69-L99

    Registration happens here in case that's relevant (the committed version doesn't contain the local changes mentioned above):

    https://github.com/djeedai/bevy_hanabi/blob/451bd340333c2b02c4bf4b073a09834d4f242654/src/plugin.rs#L71-L72

    Repro

    git clone https://github.com/djeedai/bevy_hanabi.git
    cd bevy_hanabi
    cargo r --example gradient --no-default-features --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
    

    Expand the "effect" entity, it contains a ParticleEffect component with a spawner: Option<Spawner> field.

    opened by djeedai 8
  • How can I inspect my Player component?

    How can I inspect my Player component?

    Hi! I have a player component with a direction and is_moving properties:

    #[derive(Component)]
    pub struct Player {
        direction: Direction,
        is_moving: bool,
    }
    
    enum Direction {
        Up,
        Down,
        Left,
        Right,
    }
    

    But when trying to use the inspector I can't watch to player direction or is_moving propertires. What should I do?

    opened by igortavtib 8
  • Implement Inspectable for HashMap

    Implement Inspectable for HashMap

    Would it be reasonable to have Inspectable implemented for HashMaps where the key and value are both inspectable, similar to how it's done for Vec and Tuples?

    opened by Luminoth 6
  • Disable yellow highlighting

    Disable yellow highlighting

    How would I disable the yellow highlighting on some components? It appears this is a change detection indicator but it results in a lot of flashing components in my game.

    opened by mwbryant 5
  • Upgrade rework branch dependencies

    Upgrade rework branch dependencies

    bevy_dock just released a new version with egui = "0.20.0" and inspector became incompatible with it :disappointed:. This PR is simple cargo upgrade on the rework branch.

    opened by barsoosayque 5
  • Controlling InspectorWindows

    Controlling InspectorWindows

    Is there a way to access InspectorWindows and say control when a window is open, currently forking and making it public, and adding want I need. Am I missing something?

    Still new to bevy and egui, and first time using bevy-inspector-egui. Really a pleasure to use though =-)

    opened by slyedoc 5
  • Linking Error

    Linking Error

    Trying to run any of the examples gives me a linking error:

    error: linking with `cc` failed: exit status: 1
    ...
     = note: /usr/bin/ld: cannot find -lxcb-render
              /usr/bin/ld: cannot find -lxcb-shape
              /usr/bin/ld: cannot find -lxcb-xfixes
              collect2: error: ld returned 1 exit status
    

    I'm running on Ubuntu 20.04.2 LTS Rust version stable-x86_64-unknown-linux-gnu - rustc 1.54.0

    Thanks in advance for your help.

    opened by Circuit8 4
  • Inspect a State<T> resource

    Inspect a State resource

    This doesn't appear to be possible currently. Code similar to:

    #[derive(Inspectable)]
    enum GameState { Menu, InGame }
    
    #[derive(Inspectable)]
    struct Root {
        game_state: ResourceInspector<State<GameState>>,
    }
    

    makes rustc complain about State not implementing Inspectable. If adding such impl doesn't work, introducing a dedicated StateInspector could work equally well.

    (Bonus point for support iyes_loopless states, too ;-) )

    opened by Xion 3
  • Rapier integration broken?

    Rapier integration broken?

    It seems like the integration needs to be updated for rapier 0.13. Also, how are you supposed to run the example? The crate was commented out of the cargo workspace.

    opened by SUPERCILEX 3
  • new derive InspectorOptions doesn't allow fields to refer to each other.

    new derive InspectorOptions doesn't allow fields to refer to each other.

    For example:

    #[derive(Reflect, InspectorOptions]
    struct MyAbility {
        #[inspector(min = 0, max = 10)]
        max_charges: u8,
        #[inspector(min = 0, max = self.max_charges)]
        current_charges: u8,
    }
    

    In the previous version this worked fine.

    opened by maxwellodri 2
  • #[inspectable(inner_attributes)] requires funky undocumented syntax

    #[inspectable(inner_attributes)] requires funky undocumented syntax

    For InNewWindow<T> struct fields, the corresponding WindowAttributes declare an inner_attributes value that can be set to the attributes of T. However, there is no example for doing this when deriving Inspectable through the proc-macro (#[derive(Inspectable)]) which is an issue because it doesn't follow the conventional syntax.

    Typically (c.f. popular crates like serde), when #[foo] attributes support nested values, they do so using a function-like syntax, e.g.:

    #[serde(rename(serialize = "ser_name"))]
    

    One would expect #[inspectable] to do likewise:

        #[inspectable(
            label = "Player",
            title = "Player", title_bar, resizable, scrollable,
            inner_attributes(despawnable = false),
        )]
        player: InNewWindow<InspectorQuerySingle<Entity, With<Player>>>,
    

    Unfortunately, that's not supported. I did some digging into the proc-macro code for the attribute and found that the way to make it work is to explicitly create the value for inner_attributes and assign to it:

    #[inspectable(/* ... */ inner_attributes = EntityAttributes{despawnable: false})]
    

    This is quite unusual; normally, users don't have to explicitly provide values of the crate's own types when using a #[derive] macro.

    I'd suggest providing an example of this atypical use of inner_attributes. or changing it to follow de-facto conventions of the Rust ecosystem.

    opened by Xion 0
  • min text area width?

    min text area width?

    Is there a way we can force it to not have such narrow text areas? At the moment it seems to wrap at a line length of 7 chars or so.

    egui_ctx.ctx_mut().set_style(egui::Style {
            wrap:Some(false),
            spacing: Spacing {
                text_edit_width: 1000.,
                ..default()
            },
            ..default()
        });
    

    I tried the above but it seemed to make no effect. Other things are wider so it could use up more space if it wanted to but it chooses not to. Being able to set min / max text width as an attribute would be good.

    opened by gilescope 4
Owner
Jakob Hellermann
Jakob Hellermann
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Crossterm plugin for the bevy game engine

What is bevy_crossterm? bevy_crossterm is a Bevy plugin that uses crossterm as a renderer. It provides custom components and events which allow users

null 79 Nov 2, 2022
Hanabi — a particle system plugin for the Bevy game engine.

Hanabi — a particle system plugin for the Bevy game engine

Jerome Humbert 256 Dec 30, 2022
Tweening animation plugin for the Bevy game engine.

?? Bevy Tweening Tweening animation plugin for the Bevy game engine. Features Animate any field of any component or asset, including custom ones. Run

Jerome Humbert 135 Dec 23, 2022
A plugin to enable random number generation for the Bevy game engine.

bevy_turborand A plugin to enable random number generation for the Bevy game engine, built upon turborand. Implements ideas from Bevy's Deterministic

Gonçalo Rica Pais da Silva 15 Dec 23, 2022
A spectator camera plugin for the Bevy game engine

bevy_spectator A spectator camera plugin for the Bevy game engine. Controls Action Key Forward W Left A Backward S Right D Up Space Down LControl Alt.

Jonah Henriksson 5 Jan 2, 2023
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021
A game made in one week for the Bevy engine's first game jam

¿Quien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

bevy_pen_tool A Bevy Engine plugin for making 2D paths and smooth animations with Bezier curves TODO: Mesh-making functionality for building 2D shapes

Eli 36 Dec 22, 2022
Bevy engine + miniquad render plugin

Bevy engine + miniquad renderer This is a plugin for Bevy engine that replaces default windowing and rendering plugins with miniquad based one. Usage

Tomasz Sterna 31 Dec 9, 2022
A Bevy plugin to use Kira for game audio

Bevy Kira audio This bevy plugin is intended to try integrating Kira into Bevy. The end goal would be to replace or update bevy_audio, if Kira turns o

Niklas Eicker 172 Jan 5, 2023
Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

Spencer Burris 85 Dec 23, 2022
Concise Reference Book for the Bevy Game Engine

Unofficial Bevy Cheat Book Click here to read the book! Concise reference to programming in the Bevy game engine. Covers useful syntax, features, prog

null 947 Jan 8, 2023
Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions

Introduction Proof-of-concept of getting OpenXR rendering support for Bevy game engine using gfx-rs abstractions. (hand interaction with boxes missing

Mika 52 Nov 14, 2022
A physics lib for the bevy game engine based on physme

physimple Physimple aims to be the simplest(and capable) physics engine(currently for bevy) WARNING Beware for breaking changes with each update for n

null 24 Oct 28, 2022
An immediate mode 2D drawing API for Bevy game engine

Bevy Canvas API prototype An unofficial immediate mode 2D drawing API for Bevy game engine. Check the documentation or the examples to know how to use

Federico Rinaldi 20 Apr 21, 2022
Simple RUST game with the Bevy Engine

Simple RUST Game using the Bevy Engine YouTube videos for this code base: Episode 1 - Rust Game Development tutorial from Scratch with Bevy Engine Epi

null 150 Jan 7, 2023