Skip to content

Commit

Permalink
Add error when extract resource build fails (#4964)
Browse files Browse the repository at this point in the history
# 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)
  • Loading branch information
aevyrie authored Apr 28, 2024
1 parent 22d605c commit 4b446c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/bevy_render/src/extract_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>()
);
}
}
}
Expand Down

0 comments on commit 4b446c0

Please sign in to comment.