-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
examples: Add Dynamic Types
reflection example
#13220
examples: Add Dynamic Types
reflection example
#13220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really lovely! I was butting my head against this for the dev tools RFC and I'm grateful to have such a clear explanation to refer back to.
I'm perfectly fine with this style of material living in the examples for now. Like you said, I think it's a better fit for the book in the long-term, but we can cross that bridge later :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good explanation on this feature! There is a very good amount of knowledge here that can be of use to beginners, all good.
|
||
// It also enables us to create a representation of a type without having compile-time | ||
// access to the actual type. This is how the reflection deserializers work. | ||
// They generally can't know how to construct a type ahead of time, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so I understand; they could if we just provided an API typed_deserialize<T> -> T
(instead of the deserialize -> dyn Reflect
that we have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I had considered mentioning how we could automatically use ReflectDefault
or ReflectFromReflect
internally but I figured that was an unnecessary technical note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really useful explanation, love this!
Objective
Dynamic types can be tricky to understand and work with in bevy_reflect. There should be an example that shows what they are and how they're used.
Solution
Add a
Dynamic Types
reflection example.I'm planning to go through the reflection examples, adding new ones and updating old ones. And I think this walkthrough style tends to work best. Due to the amount of text and associated explanation, it might fit better in a dedicated reflection chapter of the WIP Bevy Book. However, I think it might be valuable to have some public-facing tutorials for these concepts.
Let me know if there any thoughts or critiques with the example— both in content and this overall structure!
Testing
To test these changes, you can run the example locally:
Changelog
Dynamic Types
reflection example