diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 2bc076d205f12..eadbdaad13f29 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -5,7 +5,7 @@ use bevy_ecs::{ schedule::{ apply_state_transition, common_conditions::run_once as run_once_condition, run_enter_schedule, BoxedScheduleLabel, IntoSystemConfigs, IntoSystemSetConfigs, - ScheduleLabel, + ScheduleBuildSettings, ScheduleLabel, }, }; use bevy_utils::{tracing::debug, HashMap, HashSet}; @@ -850,6 +850,17 @@ impl App { self } + + /// Applies the provided [`ScheduleBuildSettings`] to all schedules. + pub fn configure_schedules( + &mut self, + schedule_build_settings: ScheduleBuildSettings, + ) -> &mut Self { + self.world + .resource_mut::() + .configure_schedules(schedule_build_settings); + self + } } fn run_once(mut app: App) { diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 81bc44f23a7ee..b45504b77998f 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -103,6 +103,13 @@ impl Schedules { schedule.check_change_ticks(change_tick); } } + + /// Applies the provided [`ScheduleBuildSettings`] to all schedules. + pub fn configure_schedules(&mut self, schedule_build_settings: ScheduleBuildSettings) { + for (_, schedule) in self.inner.iter_mut() { + schedule.set_build_settings(schedule_build_settings.clone()); + } + } } fn make_executor(kind: ExecutorKind) -> Box { @@ -200,6 +207,11 @@ impl Schedule { self } + /// Returns the schedule's current `ScheduleBuildSettings`. + pub fn get_build_settings(&self) -> ScheduleBuildSettings { + self.graph.settings.clone() + } + /// Returns the schedule's current execution strategy. pub fn get_executor_kind(&self) -> ExecutorKind { self.executor.kind()