-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Reflect derived traits on all components and resources #15187
Comments
This should be done, but is easy to forget. When tackling this, please handle it one crate or so at a time: it's helpful to avoid merge conflicts and review burden. |
I'm working on this but can only get started on Sunday, so no pull request just yet. I'm also wondering if a lint could be written to remind people to do this on future components and resources. |
FYI, there was talk of deprecating Edit: leave it in, per reasoning below |
I'm on the fence about deprecating it. I agree that generally speaking, the reflection-based I'd like to see benchmarks and/or a breakdown of performance, maintainability, and support implications before committing to that idea. Or at the very least, I'd like to know that Bevy is comfortable with utilizing these quasi-specialization hacks. Until then, I think it's perfectly fine—and probably desirable—to add |
Solves #15187 for the bevy_a11y subcrate.
) Solves #15187 for bevy_ecs
) Solves #15187 for bevy_pbr
I went through all subcrates and fixed everything I could find. I consider this done. |
@blazepaws much appreciated, thanks! |
What problem does this solve or what need does it fill?
Some components and resources reflect their derived traits (e.g. Name), but most only derive some of them (e.g. Transform).
To me it is unexpected that I have to manually add some fundamental traits (like Default, Debug, Serialize and Deserialize) to the reflection system retroactively. This way the user can rely on the consistency of which traits are reflected.
A practical example is a plugin I'm working on. It has to serialize entities using the reflection system.
It serializes all components that have ReflectSerialize. But by default that leads to partial serializations.
What solution would you like?
I propose to add reflection to the following traits on components and resources that implement them:
All of these are already reflected on some component.
What alternative(s) have you considered?
It is of course possible to go through the bevy code and manually register all bevy types:
The problems with this approach are:
Additional context
Additional notes:
It is necessary to benchmark compile times. The macro increases compile times. If the compile times become unacceptable the set of traits added to reflection needs to be reviewed. Taking traits out of the reflection system in a consistent manner would be breaking changes as some types already make use of these.
Feature gates need to be respected (particularly
bevy_reflect
andserialize
). At this point I still need to review which feature gates exist for which subcrates.The text was updated successfully, but these errors were encountered: