diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 94e6a124e7543..f6640a63985e7 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -1682,6 +1682,7 @@ fn despawn_entities(commands: &mut Commands, entities: Vec) { // collection. pub fn check_light_entities_needing_specialization( needs_specialization: Query>, Changed)>, + mesh_materials: Query>>, mut entities_needing_specialization: ResMut>, mut removed_components: RemovedComponents, ) { @@ -1690,7 +1691,10 @@ pub fn check_light_entities_needing_specialization( } for removed in removed_components.read() { - entities_needing_specialization.entities.push(removed); + // Only require specialization if the entity still exists. + if mesh_materials.contains(removed) { + entities_needing_specialization.entities.push(removed); + } } }