Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspectable component not working with WorldInspectorPlugin #19

Closed
Sheepyhead opened this issue May 26, 2021 · 2 comments
Closed

Inspectable component not working with WorldInspectorPlugin #19

Sheepyhead opened this issue May 26, 2021 · 2 comments

Comments

@Sheepyhead
Copy link

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
Copy link
Owner

If you want to use your own component with the world inspector, you also need to register it at the InspectableRegistry like this:

let mut registry = app
.world_mut()
.get_resource_or_insert_with(InspectableRegistry::default);
// registering custom component to be able to edit it in inspector
registry.register::<MyInspectableComponent>();

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

@Sheepyhead
Copy link
Author

That works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants