From bf4660066922ebd4dd5ca2b8e771219a2d45a4cd Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:07:27 +0100 Subject: [PATCH] catch occasional crash on spawned gltf not found --- crates/scene_runner/src/update_world/gltf_container.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/scene_runner/src/update_world/gltf_container.rs b/crates/scene_runner/src/update_world/gltf_container.rs index 8609ec52..e5f3b224 100644 --- a/crates/scene_runner/src/update_world/gltf_container.rs +++ b/crates/scene_runner/src/update_world/gltf_container.rs @@ -381,7 +381,13 @@ fn update_ready_gltfs( } let instance = loaded.0.as_ref().unwrap(); if scene_spawner.instance_is_ready(*instance) { - let gltf = gltfs.get(h_gltf).unwrap(); + let Some(gltf) = gltfs.get(h_gltf) else { + commands + .entity(bevy_scene_entity) + .try_insert(GltfProcessed::default()); + error!("gltf was unloaded mysteriously. this shouldn't happen and things will be broken as a result."); + continue; + }; // let graph = _node_graph(&_debug_query, bevy_scene_entity); // println!("{bevy_scene_entity:?}");