diff --git a/crates/bevy_render/src/extract_resource.rs b/crates/bevy_render/src/extract_resource.rs index 4233ef61b5d610..37a21f45bf84c4 100644 --- a/crates/bevy_render/src/extract_resource.rs +++ b/crates/bevy_render/src/extract_resource.rs @@ -40,24 +40,26 @@ impl Plugin for ExtractResourcePlugin { /// This system extracts the resource of the corresponding [`Resource`] type pub fn extract_resource( mut commands: Commands, - main_resource: Extract>, + main_resource: Extract>>, target_resource: Option>, #[cfg(debug_assertions)] mut has_warned_on_remove: Local, ) { - if let Some(mut target_resource) = target_resource { - if main_resource.is_changed() { - *target_resource = R::extract_resource(&main_resource); - } - } else { - #[cfg(debug_assertions)] - if !main_resource.is_added() && !*has_warned_on_remove { - *has_warned_on_remove = true; - bevy_log::warn!( - "Removing resource {} from render world not expected, adding using `Commands`. + if let Some(main_resource) = main_resource.as_ref() { + if let Some(mut target_resource) = target_resource { + if main_resource.is_changed() { + *target_resource = R::extract_resource(main_resource); + } + } else { + #[cfg(debug_assertions)] + if !main_resource.is_added() && !*has_warned_on_remove { + *has_warned_on_remove = true; + bevy_log::warn!( + "Removing resource {} from render world not expected, adding using `Commands`. This may decrease performance", - std::any::type_name::() - ); + std::any::type_name::() + ); + } + commands.insert_resource(R::extract_resource(main_resource)); } - commands.insert_resource(R::extract_resource(&main_resource)); } }