Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move scene spawner systems to SpawnScene schedule #9260

Merged
merged 6 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/bevy_app/src/main_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down Expand Up @@ -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),
],
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_scene/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -27,7 +28,7 @@ pub mod prelude {
};
}

use bevy_app::prelude::*;
use bevy_app::{prelude::*, SpawnScene};
use bevy_asset::AddAsset;

#[derive(Default)]
Expand All @@ -40,9 +41,7 @@ impl Plugin for ScenePlugin {
.add_asset::<Scene>()
.init_asset_loader::<SceneLoader>()
.init_resource::<SceneSpawner>()
.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());
}
}

Expand Down