Skip to content

Commit

Permalink
Add SceneInstanceReady
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Jul 31, 2023
1 parent 08ea1d1 commit 302ffbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/bevy_scene/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Plugin for ScenePlugin {
app.add_asset::<DynamicScene>()
.add_asset::<Scene>()
.init_asset_loader::<SceneLoader>()
.add_event::<SceneInstanceReady>()
.init_resource::<SceneSpawner>()
.add_systems(Update, scene_spawner_system)
// Systems `*_bundle_spawner` must run before `scene_spawner_system`
Expand Down
9 changes: 8 additions & 1 deletion crates/bevy_scene/src/scene_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{DynamicScene, Scene};
use bevy_asset::{AssetEvent, Assets, Handle};
use bevy_ecs::{
entity::{Entity, EntityMap},
event::{Events, ManualEventReader},
event::{Event, Events, ManualEventReader},
reflect::AppTypeRegistry,
system::{Command, Resource},
world::{Mut, World},
Expand All @@ -12,6 +12,12 @@ use bevy_utils::{tracing::error, HashMap, HashSet};
use thiserror::Error;
use uuid::Uuid;

/// Emitted when [`crate::SceneInstance`] becomes ready to use.
///
/// See also [`SceneSpawner::instance_is_ready`].
#[derive(Event)]
pub struct SceneInstanceReady(pub Entity);

/// Information about a scene instance.
#[derive(Debug)]
pub struct InstanceInfo {
Expand Down Expand Up @@ -285,6 +291,7 @@ impl SceneSpawner {
child: entity,
}
.apply(world);
world.send_event(SceneInstanceReady(parent));
}
}
} else {
Expand Down

0 comments on commit 302ffbf

Please sign in to comment.