Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bevy Reflect
This crate replaces the old
bevy_property
andbevy_type_registry
crates with a new, much more capablebevy_reflect
crate. It enables you to dynamically interact with Rust types:Why replace bevy_property?
bevy_property
used a lot of invented jargon and was built for a very specific use case.bevy_reflect
is intended to be a "generic" rust reflection cratebevy_property
had a number of limitations in how properties could be accessed (ex: nesting didn't work in some cases)bevy_property
didn't account for traits very well and it wasn't very extensiblebevy_property
used a single trait for all types and overloaded behaviors for things like maps and lists in a way that was confusing at best and in some cases, actively harmfulFeatures
Derive the Reflect traits
Interact with fields using their names
"Patch" your types with new values
Look up nested fields using "path strings"
Iterate over struct fields
Automatically serialize and deserialize via Serde (without explicit serde impls)
Trait "reflection"
Call a trait on a given &dyn Reflect reference without knowing the underlying type!
Why make this?
The whole point of Rust is static safety! Why build something that makes it easy to throw it all away?
Future Work
inventory
crate to remove the need to manually register types. I actually already integrated it, but there were two problems:inventory
(and the general approach it uses) has a show-stopping rustc buginventory
(and the general approach it uses) doesn't support wasm