Fix error in DynamicScene (#1651)

The wrong error was returned when using an unregistered type in a scene, leading to a confusing error message.
This commit is contained in:
davier 2021-03-14 20:02:10 +00:00
parent 01bb68b685
commit de55e05669
2 changed files with 9 additions and 3 deletions

View File

@ -72,7 +72,7 @@ impl DynamicScene {
for component in scene_entity.components.iter() {
let registration = type_registry
.get_with_name(component.type_name())
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
.ok_or_else(|| SceneSpawnError::UnregisteredType {
type_name: component.type_name().to_string(),
})?;
let reflect_component =

View File

@ -168,9 +168,15 @@ impl SceneSpawner {
let reflect_component = type_registry
.get(component_info.type_id().unwrap())
.and_then(|registration| registration.data::<ReflectComponent>())
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
.ok_or_else(|| SceneSpawnError::UnregisteredType {
type_name: component_info.name().to_string(),
})
.and_then(|registration| {
registration.data::<ReflectComponent>().ok_or_else(|| {
SceneSpawnError::UnregisteredComponent {
type_name: component_info.name().to_string(),
}
})
})?;
reflect_component.copy_component(
&scene.world,