Added derive Reflect to UntypedHandle and UntypedAssetId (#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>
This commit is contained in:
parent
2556405feb
commit
19682aa4c3
@ -292,7 +292,7 @@ impl<A: Asset> From<&mut Handle<A>> for UntypedAssetId {
|
||||
/// to be stored together and compared.
|
||||
///
|
||||
/// See [`Handle`] for more information.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Reflect)]
|
||||
pub enum UntypedHandle {
|
||||
/// A strong handle, which will keep the referenced [`Asset`] alive until all strong handles are dropped.
|
||||
Strong(Arc<StrongHandle>),
|
||||
|
@ -164,7 +164,7 @@ impl<A: Asset> From<AssetIndex> for AssetId<A> {
|
||||
/// An "untyped" / "generic-less" [`Asset`] identifier that behaves much like [`AssetId`], but stores the [`Asset`] type
|
||||
/// information at runtime instead of compile-time. This increases the size of the type, but it enables storing asset ids
|
||||
/// across asset types together and enables comparisons between them.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Debug, Copy, Clone, Reflect)]
|
||||
pub enum UntypedAssetId {
|
||||
/// A small / efficient runtime identifier that can be used to efficiently look up an asset stored in [`Assets`]. This is
|
||||
/// the "default" identifier used for assets. The alternative(s) (ex: [`UntypedAssetId::Uuid`]) will only be used if assets are
|
||||
|
Loading…
Reference in New Issue
Block a user