mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 14:32:06 +00:00
Add SceneInstanceReady
(#9313)
# Objective Closes #9115, replaces #9117. ## Solution Emit event when scene is ready. --- ## Changelog ### Added - `SceneInstanceReady` event when scene becomes ready.
This commit is contained in:
parent
55a710995c
commit
d60b715411
2 changed files with 13 additions and 1 deletions
|
@ -40,6 +40,7 @@ impl Plugin for ScenePlugin {
|
|||
app.add_asset::<DynamicScene>()
|
||||
.add_asset::<Scene>()
|
||||
.init_asset_loader::<SceneLoader>()
|
||||
.add_event::<SceneInstanceReady>()
|
||||
.init_resource::<SceneSpawner>()
|
||||
.add_systems(SpawnScene, (scene_spawner, scene_spawner_system).chain());
|
||||
}
|
||||
|
|
|
@ -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},
|
||||
|
@ -12,6 +12,15 @@ 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 {
|
||||
/// Entity to which the scene was spawned as a child.
|
||||
pub parent: Entity,
|
||||
}
|
||||
|
||||
/// Information about a scene instance.
|
||||
#[derive(Debug)]
|
||||
pub struct InstanceInfo {
|
||||
|
@ -285,6 +294,8 @@ impl SceneSpawner {
|
|||
child: entity,
|
||||
}
|
||||
.apply(world);
|
||||
|
||||
world.send_event(SceneInstanceReady { parent });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue