mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Remove the UpdateAssets and AssetEvents schedules (#11986)
# Objective Fix #11845. ## Solution Remove the `UpdateAssets` and `AssetEvents` schedules. Moved the `UpdateAssets` systems to `PreUpdate`, and `AssetEvents` systems into `First`. The former is meant to run before any of the event flushes. ## Future Work It'd be ideal if we could manually flush the events for assets to avoid needing two, sort of redundant, systems. This should at least let them potentially run in parallel with all of the systems in the schedules they were moved to. --- ## Changelog Removed: `UpdateAssets` schedule from the main schedule. All systems have been moved to `PreUpdate`. Removed: `AssetEvents` schedule from the main schedule. All systems have been move to `First` with the same system sets. ## Migration Guide TODO
This commit is contained in:
parent
5d941d5b91
commit
51edf9cc8f
1 changed files with 12 additions and 21 deletions
|
@ -46,10 +46,10 @@ use crate::{
|
||||||
io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId},
|
io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId},
|
||||||
processor::{AssetProcessor, Process},
|
processor::{AssetProcessor, Process},
|
||||||
};
|
};
|
||||||
use bevy_app::{App, First, MainScheduleOrder, Plugin, PostUpdate};
|
use bevy_app::{App, First, Plugin, PreUpdate};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
reflect::AppTypeRegistry,
|
reflect::AppTypeRegistry,
|
||||||
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, ScheduleLabel, SystemSet},
|
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, SystemSet},
|
||||||
system::Resource,
|
system::Resource,
|
||||||
world::FromWorld,
|
world::FromWorld,
|
||||||
};
|
};
|
||||||
|
@ -146,7 +146,6 @@ impl AssetPlugin {
|
||||||
|
|
||||||
impl Plugin for AssetPlugin {
|
impl Plugin for AssetPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_schedule(UpdateAssets).init_schedule(AssetEvents);
|
|
||||||
let embedded = EmbeddedAssetRegistry::default();
|
let embedded = EmbeddedAssetRegistry::default();
|
||||||
{
|
{
|
||||||
let mut sources = app
|
let mut sources = app
|
||||||
|
@ -218,16 +217,9 @@ impl Plugin for AssetPlugin {
|
||||||
.init_asset::<LoadedUntypedAsset>()
|
.init_asset::<LoadedUntypedAsset>()
|
||||||
.init_asset::<()>()
|
.init_asset::<()>()
|
||||||
.add_event::<UntypedAssetLoadFailedEvent>()
|
.add_event::<UntypedAssetLoadFailedEvent>()
|
||||||
.configure_sets(
|
.configure_sets(PreUpdate, TrackAssets.after(handle_internal_asset_events))
|
||||||
UpdateAssets,
|
.add_systems(PreUpdate, handle_internal_asset_events)
|
||||||
TrackAssets.after(handle_internal_asset_events),
|
|
||||||
)
|
|
||||||
.add_systems(UpdateAssets, handle_internal_asset_events)
|
|
||||||
.register_type::<AssetPath>();
|
.register_type::<AssetPath>();
|
||||||
|
|
||||||
let mut order = app.world.resource_mut::<MainScheduleOrder>();
|
|
||||||
order.insert_after(First, UpdateAssets);
|
|
||||||
order.insert_after(PostUpdate, AssetEvents);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,10 +379,13 @@ impl AssetApp for App {
|
||||||
.register_type::<Handle<A>>()
|
.register_type::<Handle<A>>()
|
||||||
.register_type::<AssetId<A>>()
|
.register_type::<AssetId<A>>()
|
||||||
.add_systems(
|
.add_systems(
|
||||||
AssetEvents,
|
First,
|
||||||
Assets::<A>::asset_events.run_if(Assets::<A>::asset_events_condition),
|
Assets::<A>::asset_events
|
||||||
|
.before(bevy_ecs::event::event_update_system::<AssetEvent<A>>)
|
||||||
|
.run_if(Assets::<A>::asset_events_condition)
|
||||||
|
.in_set(AssetEvents),
|
||||||
)
|
)
|
||||||
.add_systems(UpdateAssets, Assets::<A>::track_assets.in_set(TrackAssets))
|
.add_systems(PreUpdate, Assets::<A>::track_assets.in_set(TrackAssets))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_asset_reflect<A>(&mut self) -> &mut Self
|
fn register_asset_reflect<A>(&mut self) -> &mut Self
|
||||||
|
@ -422,14 +417,10 @@ impl AssetApp for App {
|
||||||
#[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)]
|
#[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct TrackAssets;
|
pub struct TrackAssets;
|
||||||
|
|
||||||
/// Schedule where [`Assets`] resources are updated.
|
/// A system set where events accumulated in [`Assets`] are applied to the [`AssetEvent`] [`Events`] resource.
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)]
|
|
||||||
pub struct UpdateAssets;
|
|
||||||
|
|
||||||
/// Schedule where events accumulated in [`Assets`] are applied to the [`AssetEvent`] [`Events`] resource.
|
|
||||||
///
|
///
|
||||||
/// [`Events`]: bevy_ecs::event::Events
|
/// [`Events`]: bevy_ecs::event::Events
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
pub struct AssetEvents;
|
pub struct AssetEvents;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue