Add error when extract resource build fails (#4964)

# Objective

- Provide feedback when an extraction plugin fails to add its system.

I had some troubleshooting pain when this happened to me, as the panic
only tells you a resource is missing. This PR adds an error when the
ExtractResource plugin is added before the render world exists, instead
of silently failing.


![image](https://user-images.githubusercontent.com/2632925/172491993-673d9351-215a-4f30-96f7-af239c44686a.png)
This commit is contained in:
Aevyrie 2024-04-27 22:20:59 -07:00 committed by GitHub
parent 22d605c8df
commit 4b446c020e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,6 +33,11 @@ impl<R: ExtractResource> Plugin for ExtractResourcePlugin<R> {
fn build(&self, app: &mut App) {
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
render_app.add_systems(ExtractSchedule, extract_resource::<R>);
} else {
bevy_utils::error_once!(
"Render app did not exist when trying to add `extract_resource` for <{}>.",
std::any::type_name::<R>()
);
}
}
}