Skip to content
/ bevy Public
forked from bevyengine/bevy

Commit

Permalink
Retain extracted component type. Fixes bevyengine#10284.
Browse files Browse the repository at this point in the history
  • Loading branch information
yrns committed Sep 11, 2024
1 parent a0faf9c commit 3a5c3b9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/bevy_scene/src/dynamic_scene_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_ecs::{
reflect::{AppTypeRegistry, ReflectComponent, ReflectResource},
world::World,
};
use bevy_reflect::PartialReflect;
use bevy_reflect::{PartialReflect, ReflectFromReflect};
use bevy_utils::default;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -278,7 +278,17 @@ impl<'w> DynamicSceneBuilder<'w> {
.get(type_id)?
.data::<ReflectComponent>()?
.reflect(original_entity)?;
entry.components.push(component.clone_value());

// Clone the via `FromReflect`. Unlike `PartialReflect::clone_value` this
// retains the original type and `ReflectSerialize` type data which is needed to
// deserialize.
let component = type_registry
.get(type_id)?
.data::<ReflectFromReflect>()?
.from_reflect(component.as_partial_reflect())?
.into_partial_reflect();

entry.components.push(component);
Some(())
};
extract_and_push();
Expand Down

0 comments on commit 3a5c3b9

Please sign in to comment.