Code Monkey home page Code Monkey logo

bevy-inspector-egui's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bevy-inspector-egui's Issues

Isolation of Bevy-independent code

Is it at all possible to restructure things such that the egui functionality isn't as tethered to the bevy ECS model? I would like to utilize this crate in a bevy project, but to to me it seems more natural for this inspection functionality to basically consist of:

fn inspect<I: Inspectable>(i: &I, ui: &mut egui::Ui) -> bool;

fn inspect_mut<I: Inspectable>(i: &mut I, ui: &mut egui::Ui) -> bool;

The base intended use case for this is just to modify my app's preferences, which lives in a ResMut, not a component.

I understand this constitutes a large change, and it probably makes more sense for any result of this change to exist as a fork rather than a direct change to this repo.

Re-export `bevy_egui::EguiContext` as well?

Hi!

I managed to get bevy-inspector-egui to play nicely with mouse interaction outside of the GUI, by checking CtxRef::wants_mouse_input() and disabling mouse interactivity for the camera, picker etc. Like this:

// system
fn data_ui(
    egui: Res<bevy_egui::EguiContext>,
    mut cameras: Query<&mut CameraRig>,
) {
    for mut c in cameras.iter_mut() {
        c.disable = egui.ctx.wants_mouse_input();
    }
}

The problem is that bevy-inspector-egui does not re-export bevy_egui::EguiContext, so I have to import the crate manually. This means that there are potentially two versions of bevy_egui which can get out of sync.

To support this use-case, could this crate re-export bevy_egui::EguiContext ? I see it already re-exports bevy_egui::egui;

Thanks!
Tom

WorldInspector component sorting

I think it would be useful to be able to sort the components when inspecting an entity with the WorldInspector. I think sorting by name would be a good default.

Update to Bevy 0.7

Bevy 0.7 has been released, so plugins for it will need to be updated.

Smaller fonts / decorations

Not so much an issue - I'm just curious if there is a way to configure the font size and the size of the UI element decorations. I have a window that's 1024x576 and I'd like to be able to fit more of the inspector content into that space if I can.

Problem with tuple structs and WorldInspector

I have a few components defined as tuple structs, and when I try to inspect them it says "Inspectable has not been defined for this component". It works great for anything else tho, great plugin btw :)

Example from my project

#[derive(Clone, Inspectable)]
pub struct Health(pub u32);

#[derive(Clone, Inspectable)]
pub struct Damage(pub u32);

and here is the screenshot
Screenshot 2021-04-25 at 17 27 38

Upgrade to bevy 0.8

Bevy 0.8 just come out. So this is a tracking issue to upgrade to newest bevy version.

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 =-)

Option to split entity list & components

As titled, I think it might be worth to experiment with layout of the UI, in this case the entities and their relations stay in top half of the window and second half would be dedicated to the components.

Is there a way to add a slider?

Hi,
first of all, amazing crate!

I was wondering if there is a way to add a slider. Similar to the Vec2 visual, but in a single dimension.
My scenario is that I have lots of floats [0, 1] that a gradual increase on a slider would work very well.

Thanks!

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.

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. :)

`Option<T>` not handled properly

It seems that, while we can revert an Option<T> back to None, there is no way to convert it back to Some(...).

Screen Shot 2021-04-11 at 6 48 18 PM

Screen Shot 2021-04-11 at 6 48 27 PM

Perhaps Option<T> should be handled by a checkbox (indicating None when off, and Some when on), and a textbox that appears to the right of it when on.

Filter entities By name in the World Inspector

Hello, In my project I've implemented the ability to filter entities by name using an Option<String> in the WorldInspectorParams struct. If this is a feature you would like I'll have some time the next couple of days to submit a PR.

Here is an image of my Project that shows it in use.
DevToolsImage

Currently it calls to_lowercase on both the entity name & the filter_string but an option to change this behavior would be trivial to add later.

make WorldUIContext public

Would it be possible to make WorldUIContext as well as the world_ui functions public?

I'm trying to embed the WorldInspector in a preexisting egui window

Quaternion values are not updated when modified outside the inspector

Thanks so much for this great plugin ๐Ÿ’ฏ

I noticed that when manipulating Transforms manually, the changes to the rotation are not updated (changes to Quat in general). I tried both WorldInspectorPlugin and InspectorPlugin. Notice the rotation not updating

Peek 2022-01-23 21-19

Above is small change to examples/transform.rs to rotate and translate the cube and set data.transform from the cube's transform

fn rotate_and_translate(mut query: Query<&mut Transform, With<Cube>>) {
    query.single_mut().rotation *= Quat::from_rotation_y(0.01);
    query.single_mut().translation += 0.0001;
}

fn update(mut data: ResMut<Data>, mut query: Query<(&Cube, &mut Transform)>) {
    for (_, mut transform) in query.iter_mut() {
        data.transform = *transform;
    }
}

Looking at the code, from what I can tell, it is likely related to the fact that they are cached, maybe without updating context.id(). As long as the value can change outside the inspector, I am not sure what the correct solution is.

If it is important to avoid the recalculation (?), keeping track instead whether the raw Quat value has changed instead? Apologies if this is not correct -- could the problem be that context.id() should have changed? Not familiar with egui and how to use Id.

            QuatDisplay::Euler => {
                let mut euler_angles = ui
                    .memory()
                    .data
                    .get_temp_mut_or_insert_with(context.id(), || {
                        Euler(Vec3::from(self.to_euler(EulerRot::XYZ)))
                    })
                    .0;

                let changed = euler_angles.ui(ui, Default::default(), context);
                if changed {
                    *self = Quat::from_euler(
                        EulerRot::XYZ,
                        euler_angles.x,
                        euler_angles.y,
                        euler_angles.z,
                    );
                    ui.memory()
                        .data
                        .insert_temp(context.id(), Euler(euler_angles));
                }
                changed
            }

Panic in texture example

tested

main (7fa7125)

panic

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/impls/with_context.rs:98:83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

repro

 cargo run --example texture --features="bevy/png"

Click textures

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?

Inspectable without UI?

Hi!

I have the following project structure:

  • shared
  • client
  • server

With server, I call in structs from shared, which I want to be inspectable from the client. But to do this I need to include bevy-inspector-egui in shared, which then means the server has to pull in GUI assets.

Is it possible to just include the inspectable part in shared and use bevy-inspector-gui in the client app but not the server app?

Transform.rotation is changed visually/incorrectly in the world inspector

Modifying Transform.rotation of one entity in the world inspector changes visual representation of the Transform.rotation of other entity. Although GlobalTransform.rotation may change, Transform.rotation must not change because it is local to the entity space. Therefore, I think that there is something wrong with the Transform.rotation presentation in the world inspector.

Here is a demo video. Notice the other's Transform.rotation being changed when changing Transform.rotation of an entity.

2021-06-18.23-01-28.mp4

bevy_rapier2d

Would it be possible to split the rapier feature into rapier3d and rapier2d (or if there's a better answer to that) so that it can be used in 2d projects as well as 3d?

the trait `Inspectable` is not implemented for `VecDeque<T>`

#[cfg_attr(feature = "debug", derive(bevy_inspector_egui::Inspectable))]
#[derive(Debug, Clone,  Default, Component, Reflect, Serialize, Deserialize)]
#[reflect_value(Component,  Serialize, Deserialize)]
pub struct ActorMission {
    pub move_command: VecDeque<MoveCommand>
}

I add inpsectable trait for struct, but got the trait Inspectable is not implemented for VecDeque<movement::component::MoveCommand>

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.

Broken link(s?) in README on docs.rs

If you want to only display some components, you may want to use the InspectorQuery instead.

That InspectorQuery link fails on docs.rs because it's relative to the package but docs.rs links it relative to the website:

image

That's probably a widespread issue if relative links are used everywhere.

Identifying entities by their component marker

I know that it is possible to add a Name component to an entity. But I had an idea: if an entity has one component marker, then in the inspector, instead of the Entity, insert the name of this component. Most likely, it is impossible to do this in Rust (Rast is not a dynamic programming language), and if possible, I think it will be quite slow (most likely you will have to iterate through all the components of each entity), but I am not so experienced to confidently state this. But suddenly it's possible :)

Read-only and hidden fields

Would it be possible to add options to the Inspectable attributes to make fields in an inspectable struct hidden or read-only?

Inspectable with vec of generic type

Hey,

thanks for the awesome crate!

Maybe you can help me with an issue I ran into: I have a resource Table which I want to inspect at runtime:

#[derive(Inspectable)]
pub struct Table<T: Copy + Debug + Clone> {
    pub radius: Distance, 
    pub size: Distance,
    pub tiles: Vec<T>, 
}

T can be different types of Tiles, therefore it's generic.

It keeps telling me struct defined here, with 1 type parameter: "T"

Is there a way to make the struct inspectable?

`InspectorQuery::<T>` does not apply mutations

This was already broken for me in 0.8.0, and still in 0.8.1.

Any of these forms work as expected:

.add_plugin(WorldInspectorPlugin::new())
// OR
.add_plugin(InspectorPlugin::<InspectorQuerySingle<Entity, With<Animator<Transform>>>>::new())

But this form produces an inspector that, when a value is mutated (here, the Animator<T>::state field), does not mutate the target component:

.add_plugin(InspectorPlugin::<Animator<Transform>>::new())

The generic Animator<T> is defined as:

#[derive(Component)]
#[cfg_attr(feature = "bevy_inspector_egui", derive(Inspectable))]
pub struct Animator<T: Component> {
    pub state: AnimatorState, // some Inspectable-derived C-style enum
    #[cfg_attr(feature = "bevy_inspector_egui", inspectable(ignore))]
    prev_state: AnimatorState,
    #[cfg_attr(feature = "bevy_inspector_egui", inspectable(ignore))]
    tweenable: Option<Box<dyn Tweenable<T> + Send + Sync + 'static>>,
}

...and the bevy_inspector_egui feature is used.

Inspectable attribute causes compiler error on enums with doc comments

When adding documentation comments to enum elements, the program fails to compile.

for example:

use bevy::prelude::*;
use bevy_inspector_egui::Inspectable;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .run();
}

#[derive(Inspectable)]
enum Test {
    /// blabla bla
    A,
    /// blabla bla
    B,
}

compiler error:

error: proc-macro derive panicked
  --> src/main.rs:10:10
   |
10 | #[derive(Inspectable)]
   |          ^^^^^^^^^^^
   |
   = help: message: attributes are not supported on enum variants

error: aborting due to previous error

The program compiles if you remove a single slash from the doc comment.

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.

Vec2 inspector should show fields by default

I noticed by default, the inspector for Vec2 shows a graph of some kind. It seems more useful to show the fields by default, like it does for Vec3. I think it'd be better to show the graph by marking a field with an attribute.

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?

Inspectable component not working with WorldInspectorPlugin

Hi, I have a project where I simply add the WorldInspectorPlugin and everything worked smoothly until I had to inspect a component struct I'd made myself. I derived Inspectable for the struct (and for the custom types the struct contains all the way down until I hit primitives) and yet when I attempt to inspect it in the GUI, I still get "inspectable has not been defined for this component" despite the fact that the Inspectable trait is derived on the component struct and the code does compile and run. If nothing else, this seems like it shouldn't compile.

image

image

Troubles with Inspectable

I am trying to integrate your branch with my code but I am getting following error.

Any idea how can I mitigate this?

Bonus question: Is WorldInspectorPlugin supposed to work?

    | #[derive(Inspectable)]
    |          ^^^^^^^^^^^
    |          |
    |          expected struct `bevy_app::app::App`, found struct `bevy::prelude::App`
    |          help: change the parameter type to match the trait: `&mut bevy_app::app::App`
    |
    = note: expected fn pointer `fn(&mut bevy_app::app::App)`
               found fn pointer `fn(&mut bevy::prelude::App)`
    = note: this error originates in the derive macro `Inspectable` (in Nightly builds, run with -Z macro-backtrace for more info)

world example image is out of date

I spent way too long trying to figure out how to add the Generate button in the current screenshot. Couldnt see it anywhere in the source so I have attached newer screenshot.

image

Add name to entity based on component

Is there a way I can rename an entity based on it's component? For example, I have an entity with a Player component... I want it to be labelled as Player rather than Entity (4).

I tried adding #[derive(Reflect)] and #[reflect(Component)] to the component, but it doesn't seem to work.
It seems like Text and camera_2d components are labelled correctly but I'm not sure how to do so for custom components.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.