jakobhellermann / bevy-inspector-egui Goto Github PK
View Code? Open in Web Editor NEWInspector plugin for the bevy game engine
License: Apache License 2.0
Inspector plugin for the bevy game engine
License: Apache License 2.0
Currently bevy_ui is on a very early stage and most people use egui for ui.
So I suggest to make bevy_ui
optional.
Is there a way to customize the inspector's window size, border radius, resizability, etc?
The bevy world inspector is excellent and has helped me out of a few holes already. I would love to use the standard inspector with the bevy mod picking. Is there a way to hint to the inspector what it should be inspecting?
( https://docs.rs/bevy_mod_picking/latest/bevy_mod_picking/ )
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.
Couldn't find any info on this, is it possible to toggle the window using a keypress?
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
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.
Bevy 0.7 has been released, so plugins for it will need to be updated.
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.
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);
Bevy 0.8 just come out. So this is a tracking issue to upgrade to newest bevy version.
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 =-)
Per title. Happy to do it if you are good with a PR.
Cheers,
--Joseph
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.
When you use the UI to rotate an object, you can generate a non-unit quaternion which doesn't correctly describe a rotation. Ideally the UI would enforce this constraint.
https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/src/impls/bevy_impls.rs#L27-L29
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!
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.
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. :)
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.
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.
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
Thanks so much for this great plugin ๐ฏ
I noticed that when manipulating Transform
s 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
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
}
main (7fa7125)
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
cargo run --example texture --features="bevy/png"
Click textures
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?
Hi!
I have the following project structure:
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?
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.
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?
#[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>
At head if i remove "dynamic" from dev-dependencies then it links/runs fine.
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.
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:
That's probably a widespread issue if relative links are used everywhere.
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 :)
Would it be possible to add options to the Inspectable attributes to make fields in an inspectable struct hidden or read-only?
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?
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.
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.
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.
I realise I can use the built-in Name
component provided by Bevy.
Originally posted by @tqwewe in #48 (comment)
Can you give an example?
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.
From
, this feature already exists. However, it does not appear to be demonstrated in the examples, and is tricky for new users to discover.A very simple dedicated example showing how and why to use this feature would be helpful!
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:
rapier2d
feature set:bevy-inspector-egui = { version="0.6.1", features=["rapier2d"]}
WorldInspectorPlugin
app.add_plugin(WorldInspectorPlugin::new());
Is there anything I am missing in order to get this going?
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.
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)
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.
Bevy 0.5 support
CHANGELOG.md is missing information about versions 0.12.0 and 0.12.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.