Skip to content

Added derive Reflect to UntypedHandle and UntypedAssetId #18827

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

fredericvauchelles
Copy link
Contributor

@fredericvauchelles fredericvauchelles commented Apr 13, 2025

Objective

  • We have the ability to serialize/deserialize Handle<T> with TypedReflectSerializer and TypedReflectDeserializer, but it is not possible for UntypedHandle.
  • Handle<T> already has the Reflect derive, so it sounds coherent to also have this derive also on the untyped API

Solution

  • Add the Reflect derive macro to both UntypedHandle and UntypedAssetId.

Testing

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@djeedai djeedai added C-Feature A new feature, making something new possible A-Assets Load files from disk to use for things like images, models, and sounds A-Reflection Runtime information about types labels Apr 19, 2025
@andriyDev andriyDev added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Apr 19, 2025
@mockersf mockersf added this pull request to the merge queue Apr 28, 2025
Merged via the queue into bevyengine:main with commit 19682aa Apr 28, 2025
41 checks passed
splo pushed a commit to splo/bevy that referenced this pull request Apr 29, 2025
…18827)

# Objective

- We have the ability to serialize/deserialize `Handle<T>` with
[`TypedReflectSerializer`](https://docs.rs/bevy/latest/bevy/reflect/serde/struct.TypedReflectSerializer.html)
and
[`TypedReflectDeserializer`](https://docs.rs/bevy/latest/bevy/reflect/serde/struct.TypedReflectDeserializer.html),
but it is not possible for `UntypedHandle`.
- `Handle<T>` already has the `Reflect` derive, so it sounds coherent to
also have this derive also on the untyped API

## Solution

- Add the `Reflect` derive macro to both `UntypedHandle` and `
UntypedAssetId`.

## Testing

- I used a custom processor to handle the serialization based on the
example of
[`TypedReflectSerializer`](https://docs.rs/bevy/latest/bevy/reflect/serde/struct.TypedReflectSerializer.html)
(see [source
code](https://docs.rs/bevy_reflect/0.15.3/src/bevy_reflect/serde/ser/serializer.rs.html#149))

Co-authored-by: Frédéric Vauchelles <frederic.vauchelles@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Reflection Runtime information about types C-Feature A new feature, making something new possible S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants