From 0b038de5848e1651b3faafa0f1a9a26dfc7b384d Mon Sep 17 00:00:00 2001 From: Chris Biscardi Date: Mon, 29 Jul 2024 01:17:36 -0700 Subject: [PATCH] feat(components): warn instead of crash when components aren't reflectable (#207) * warn instead of panic when components aren't reflectable * entities get marked as processed even if components are not inserted --- crates/blenvy/src/components/process_gltfs.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/blenvy/src/components/process_gltfs.rs b/crates/blenvy/src/components/process_gltfs.rs index 4e5b176..c7b9edb 100644 --- a/crates/blenvy/src/components/process_gltfs.rs +++ b/crates/blenvy/src/components/process_gltfs.rs @@ -8,7 +8,7 @@ use bevy::{ }, gltf::{GltfExtras, GltfMaterialExtras, GltfMeshExtras, GltfSceneExtras}, hierarchy::Parent, - log::debug, + log::{debug, warn}, reflect::{Reflect, TypeRegistration}, utils::HashMap, }; @@ -145,10 +145,12 @@ pub fn add_components_from_gltf_extras(world: &mut World) { { let mut entity_mut = world.entity_mut(entity); - type_registration - .data::() - .expect("Unable to reflect component") - .insert(&mut entity_mut, &*component, &type_registry); + let Some(reflected_component) = type_registration.data::() else { + warn!(?component, "unable to reflect component"); + entity_mut.insert(GltfProcessed); + continue; + }; + reflected_component.insert(&mut entity_mut, &*component, &type_registry); entity_mut.insert(GltfProcessed); // }