From 5a0c09d38fd63383281991da9d6c353ad7228f50 Mon Sep 17 00:00:00 2001 From: Blazepaws <157802762+blazepaws@users.noreply.github.com> Date: Sun, 15 Sep 2024 20:19:44 +0200 Subject: [PATCH] Reflect derived traits on all components and resources: bevy_transform (#15230) Fixes https://github.com/bevyengine/bevy/issues/15187 for bevy_transform --- crates/bevy_transform/src/components/global_transform.rs | 8 +++++++- crates/bevy_transform/src/components/transform.rs | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index dd8f4ca08f..0b37756796 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -6,6 +6,8 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::{Affine3A, Dir3, Isometry3d, Mat4, Quat, Vec3, Vec3A}; #[cfg(feature = "bevy-support")] use bevy_reflect::{std_traits::ReflectDefault, Reflect}; +#[cfg(all(feature = "bevy-support", feature = "serialize"))] +use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; /// [`GlobalTransform`] is an affine transformation from entity-local coordinates to worldspace coordinates. /// @@ -39,7 +41,11 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; #[cfg_attr( feature = "bevy-support", derive(Component, Reflect), - reflect(Component, Default, PartialEq) + reflect(Component, Default, PartialEq, Debug) +)] +#[cfg_attr( + all(feature = "bevy-support", feature = "serialize"), + reflect(Serialize, Deserialize) )] pub struct GlobalTransform(Affine3A); diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index f0d8901745..9202b0618c 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -3,7 +3,7 @@ use super::GlobalTransform; use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::{Affine3A, Dir3, Isometry3d, Mat3, Mat4, Quat, Vec3}; #[cfg(feature = "bevy-support")] -use bevy_reflect::{prelude::*, Reflect}; +use bevy_reflect::prelude::*; use std::ops::Mul; /// Describe the position of an entity. If the entity has a parent, the position is relative @@ -38,7 +38,11 @@ use std::ops::Mul; #[cfg_attr( feature = "bevy-support", derive(Component, Reflect), - reflect(Component, Default, PartialEq) + reflect(Component, Default, PartialEq, Debug) +)] +#[cfg_attr( + all(feature = "bevy-support", feature = "serialize"), + reflect(Serialize, Deserialize) )] pub struct Transform { /// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.