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

Remove the UpdateAssets and AssetEvents schedules #11986

Merged
merged 3 commits into from
Feb 26, 2024
Merged
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
33 changes: 12 additions & 21 deletions crates/bevy_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ use crate::{
io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId},
processor::{AssetProcessor, Process},
};
use bevy_app::{App, First, MainScheduleOrder, Plugin, PostUpdate};
use bevy_app::{App, First, Plugin, PreUpdate};
use bevy_ecs::{
reflect::AppTypeRegistry,
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, ScheduleLabel, SystemSet},
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, SystemSet},
system::Resource,
world::FromWorld,
};
Expand Down Expand Up @@ -146,7 +146,6 @@ impl AssetPlugin {

impl Plugin for AssetPlugin {
fn build(&self, app: &mut App) {
app.init_schedule(UpdateAssets).init_schedule(AssetEvents);
let embedded = EmbeddedAssetRegistry::default();
{
let mut sources = app
Expand Down Expand Up @@ -218,16 +217,9 @@ impl Plugin for AssetPlugin {
.init_asset::<LoadedUntypedAsset>()
.init_asset::<()>()
.add_event::<UntypedAssetLoadFailedEvent>()
.configure_sets(
UpdateAssets,
TrackAssets.after(handle_internal_asset_events),
)
.add_systems(UpdateAssets, handle_internal_asset_events)
.configure_sets(PreUpdate, TrackAssets.after(handle_internal_asset_events))
.add_systems(PreUpdate, handle_internal_asset_events)
.register_type::<AssetPath>();

let mut order = app.world.resource_mut::<MainScheduleOrder>();
order.insert_after(First, UpdateAssets);
order.insert_after(PostUpdate, AssetEvents);
}
}

Expand Down Expand Up @@ -387,10 +379,13 @@ impl AssetApp for App {
.register_type::<Handle<A>>()
.register_type::<AssetId<A>>()
.add_systems(
AssetEvents,
Assets::<A>::asset_events.run_if(Assets::<A>::asset_events_condition),
First,
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
Expand Down Expand Up @@ -422,14 +417,10 @@ impl AssetApp for App {
#[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)]
pub struct TrackAssets;

/// Schedule where [`Assets`] resources are updated.
#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)]
pub struct UpdateAssets;

/// Schedule where events accumulated in [`Assets`] are applied to the [`AssetEvent`] [`Events`] resource.
/// A system set where events accumulated in [`Assets`] are applied to the [`AssetEvent`] [`Events`] resource.
///
/// [`Events`]: bevy_ecs::event::Events
#[derive(Debug, Hash, PartialEq, Eq, Clone, ScheduleLabel)]
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
pub struct AssetEvents;

#[cfg(test)]
Expand Down