Skip to content

Commit d0ed3ab

Browse files
IceSentrymockersf
authored andcommitted
Move trigger_screenshots to finish() (#19204)
# Objective - The tigger_screenshots system gets added in `.build()` but relies on a resource that is only inserted in `.finish()` - This isn't a bug for most users, but when doing headless mode testing it can technically work without ever calling `.finish()` and did work before bevy 0.15 but while migrating my work codebase I had an issue of test failing because of this ## Solution - Move the trigger_screenshots system to `.finish()` ## Testing - I ran the screenshot example and it worked as expected
1 parent 2722162 commit d0ed3ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_render/src/view/window/screenshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ impl Plugin for ScreenshotPlugin {
403403
.after(event_update_system)
404404
.before(ApplyDeferred),
405405
)
406-
.add_systems(Update, trigger_screenshots)
407406
.register_type::<Screenshot>()
408407
.register_type::<ScreenshotCaptured>();
409408

@@ -417,7 +416,8 @@ impl Plugin for ScreenshotPlugin {
417416

418417
fn finish(&self, app: &mut bevy_app::App) {
419418
let (tx, rx) = std::sync::mpsc::channel();
420-
app.insert_resource(CapturedScreenshots(Arc::new(Mutex::new(rx))));
419+
app.add_systems(Update, trigger_screenshots)
420+
.insert_resource(CapturedScreenshots(Arc::new(Mutex::new(rx))));
421421

422422
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
423423
render_app

0 commit comments

Comments
 (0)