@@ -56,6 +56,8 @@ pub struct App {
56
56
pub runner : Box < dyn Fn ( App ) > ,
57
57
/// A container of [`Stage`]s set to be run in a linear order.
58
58
pub schedule : Schedule ,
59
+ /// A stage run after main schedule and sub app schedules
60
+ pub final_stage : SystemStage ,
59
61
sub_apps : HashMap < Box < dyn AppLabel > , SubApp > ,
60
62
}
61
63
@@ -98,6 +100,7 @@ impl App {
98
100
Self {
99
101
world : Default :: default ( ) ,
100
102
schedule : Default :: default ( ) ,
103
+ final_stage : SystemStage :: single_threaded ( ) ,
101
104
runner : Box :: new ( run_once) ,
102
105
sub_apps : HashMap :: default ( ) ,
103
106
}
@@ -115,6 +118,7 @@ impl App {
115
118
for sub_app in self . sub_apps . values_mut ( ) {
116
119
( sub_app. runner ) ( & mut self . world , & mut sub_app. app ) ;
117
120
}
121
+ self . final_stage . run ( & mut self . world ) ;
118
122
}
119
123
120
124
/// Starts the application by calling the app's [runner function](Self::set_runner).
@@ -326,6 +330,15 @@ impl App {
326
330
self . add_system_to_stage ( CoreStage :: Update , system)
327
331
}
328
332
333
+ /// Adds a system to the final stage that runs after the app and render schedules.
334
+ pub fn add_system_to_final_stage < Params > (
335
+ & mut self ,
336
+ system : impl IntoSystemDescriptor < Params > ,
337
+ ) -> & mut Self {
338
+ self . final_stage . add_system ( system) ;
339
+ self
340
+ }
341
+
329
342
/// Adds a [`SystemSet`] to the [update stage](Self::add_default_stages).
330
343
///
331
344
/// # Examples
0 commit comments