jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.19k stars 173 forks source link

Inspectable component not working with WorldInspectorPlugin #19

Closed Sheepyhead closed 3 years ago

Sheepyhead commented 3 years ago

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

jakobhellermann commented 3 years ago

If you want to use your own component with the world inspector, you also need to register it at the InspectableRegistry like this: https://github.com/jakobhellermann/bevy-inspector-egui/blob/4dcfb246a4831505ca5b27f66abe8adad875a11f/examples/world.rs#L20-L25

This is neccessary because otherwise bevy has no way of knowing what traits a component implements.

Sheepyhead commented 3 years ago

That works, thanks!