From b29ff79ee5479651c9ba4a4a3be3df576d1d64ab Mon Sep 17 00:00:00 2001 From: Marco Buono Date: Sat, 20 Jan 2024 23:32:50 -0300 Subject: [PATCH 1/2] Fix reflected serialization/deserialization on `Name` component --- crates/bevy_core/src/name.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bevy_core/src/name.rs b/crates/bevy_core/src/name.rs index 1f6f40c7cec42..f41c78e0c40c2 100644 --- a/crates/bevy_core/src/name.rs +++ b/crates/bevy_core/src/name.rs @@ -10,6 +10,9 @@ use std::{ ops::Deref, }; +#[cfg(feature = "serialize")] +use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; + /// Component used to identify an entity. Stores a hash for faster comparisons. /// /// The hash is eagerly re-computed upon each update to the name. @@ -19,6 +22,7 @@ use std::{ /// used instead as the default unique identifier. #[derive(Reflect, Component, Clone)] #[reflect(Component, Default, Debug)] +#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))] pub struct Name { hash: u64, // TODO: Shouldn't be serialized name: Cow<'static, str>, From 344e4f2378d49a9fdeedc84103d464b5768999de Mon Sep 17 00:00:00 2001 From: Marco Buono Date: Sat, 20 Jan 2024 23:39:34 -0300 Subject: [PATCH 2/2] Remove now completed TODO comment, add context --- crates/bevy_core/src/name.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_core/src/name.rs b/crates/bevy_core/src/name.rs index f41c78e0c40c2..dfa4a11c118bd 100644 --- a/crates/bevy_core/src/name.rs +++ b/crates/bevy_core/src/name.rs @@ -24,7 +24,7 @@ use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; #[reflect(Component, Default, Debug)] #[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))] pub struct Name { - hash: u64, // TODO: Shouldn't be serialized + hash: u64, // Won't be serialized (see: `bevy_core::serde` module) name: Cow<'static, str>, }