diff --git a/crates/bevy_app/Cargo.toml b/crates/bevy_app/Cargo.toml index e386e00c2ddac2..2dd25147e42f9b 100644 --- a/crates/bevy_app/Cargo.toml +++ b/crates/bevy_app/Cargo.toml @@ -20,6 +20,7 @@ bevy_derive = { path = "../bevy_derive", version = "0.8.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.8.0-dev", default-features = false } bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", optional = true } bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" } +bevy_tasks = { path = "../bevy_tasks", version = "0.8.0-dev" } # other serde = { version = "1.0", features = ["derive"], optional = true } diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index cdf1984c8b01e8..d587344d6549b5 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -10,6 +10,7 @@ use bevy_ecs::{ system::Resource, world::World, }; +use bevy_tasks::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool}; use bevy_utils::{tracing::debug, HashMap}; use std::fmt::Debug; @@ -862,9 +863,18 @@ impl App { pub fn add_sub_app( &mut self, label: impl AppLabel, - app: App, + mut app: App, sub_app_runner: impl Fn(&mut World, &mut App) + 'static, ) -> &mut Self { + if let Some(pool) = self.world.get_resource::() { + app.world.insert_resource(pool.clone()); + } + if let Some(pool) = self.world.get_resource::() { + app.world.insert_resource(pool.clone()); + } + if let Some(pool) = self.world.get_resource::() { + app.world.insert_resource(pool.clone()); + } self.sub_apps.insert( Box::new(label), SubApp {