diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index 194185c366ae7..f72ac80fb00cc 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -79,6 +79,11 @@ pub struct FixedUpdate; #[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash)] pub struct Update; +/// The schedule that contains scene spawning. +/// This is run by the [`Main`] schedule. +#[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash)] +pub struct SpawnScene; + /// The schedule that contains logic that must run after [`Update`]. For example, synchronizing "local transforms" in a hierarchy /// to "global" absolute transforms. This enables the [`PostUpdate`] transform-sync system to react to "local transform" changes in /// [`Update`] without the [`Update`] systems needing to know about (or add scheduler dependencies for) the "global transform sync system". @@ -112,6 +117,7 @@ impl Default for MainScheduleOrder { Box::new(StateTransition), Box::new(RunFixedUpdateLoop), Box::new(Update), + Box::new(SpawnScene), Box::new(PostUpdate), Box::new(Last), ], diff --git a/crates/bevy_scene/src/lib.rs b/crates/bevy_scene/src/lib.rs index e3ca8a2fee573..655675e3f32de 100644 --- a/crates/bevy_scene/src/lib.rs +++ b/crates/bevy_scene/src/lib.rs @@ -11,6 +11,7 @@ mod scene_spawner; #[cfg(feature = "serialize")] pub mod serde; +use bevy_ecs::schedule::IntoSystemConfigs; pub use bundle::*; pub use dynamic_scene::*; pub use dynamic_scene_builder::*; @@ -27,7 +28,7 @@ pub mod prelude { }; } -use bevy_app::prelude::*; +use bevy_app::{prelude::*, SpawnScene}; use bevy_asset::AddAsset; #[derive(Default)] @@ -40,9 +41,7 @@ impl Plugin for ScenePlugin { .add_asset::() .init_asset_loader::() .init_resource::() - .add_systems(Update, scene_spawner_system) - // Systems `*_bundle_spawner` must run before `scene_spawner_system` - .add_systems(PreUpdate, scene_spawner); + .add_systems(SpawnScene, (scene_spawner, scene_spawner_system).chain()); } }