feat: derive Serialize on Childof (#19336)
# Objective allow serialization / deserialization on the `ChildOf` entity, for example in network usage. my usage was for the bevy_replicon crate, to replicate `ChildOf`. ## Solution same implementation of serde as other types in the bevy repo --------- Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
This commit is contained in:
parent
125fbb05d3
commit
ca5712a7bf
@ -19,6 +19,8 @@ use crate::{
|
||||
use alloc::{format, string::String, vec::Vec};
|
||||
#[cfg(feature = "bevy_reflect")]
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
#[cfg(all(feature = "serialize", feature = "bevy_reflect"))]
|
||||
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||
use core::ops::Deref;
|
||||
use core::slice;
|
||||
use disqualified::ShortName;
|
||||
@ -96,9 +98,14 @@ use log::warn;
|
||||
feature = "bevy_reflect",
|
||||
reflect(Component, PartialEq, Debug, FromWorld, Clone)
|
||||
)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(
|
||||
all(feature = "serialize", feature = "bevy_reflect"),
|
||||
reflect(Serialize, Deserialize)
|
||||
)]
|
||||
#[relationship(relationship_target = Children)]
|
||||
#[doc(alias = "IsChild", alias = "Parent")]
|
||||
pub struct ChildOf(pub Entity);
|
||||
pub struct ChildOf(#[entities] pub Entity);
|
||||
|
||||
impl ChildOf {
|
||||
/// The parent entity of this child entity.
|
||||
|
Loading…
Reference in New Issue
Block a user