Move scene spawner systems to SpawnScene schedule (#9260)
# Objective - Fixes https://github.com/bevyengine/bevy/issues/9250 ## Changelog - Move scene spawner systems to a new SpawnScene schedule which is after Update and before PostUpdate (schedule order: [PreUpdate][Update][SpawnScene][PostUpdate]) ## Migration Guide - Move scene spawner systems to a new SpawnScene schedule which is after Update and before PostUpdate (schedule order: [PreUpdate][Update][SpawnScene][PostUpdate]), you might remove system ordering code related to scene spawning as the execution order has been guaranteed by bevy engine. --------- Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
This commit is contained in:
		
							parent
							
								
									505b9a58bd
								
							
						
					
					
						commit
						55a710995c
					
				@ -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),
 | 
			
		||||
            ],
 | 
			
		||||
 | 
			
		||||
@ -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::<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());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user