Skip to content

Commit 132fb4d

Browse files
committed
Fix adding outline when SceneSpawner is not in the world
Bevy removes it from the world when a scene is spawned via `SceneSpawner`: https://github.com/bevyengine/bevy/blob/f667c282dad2c1419afb5836ded22a3ec263970e/crates/bevy_scene/src/scene_spawner.rs#L560 If `AsyncSceneInheritOutline` is inserted during the scene spawning (via a required component or via trigger), the system won't run since it requires `SceneSpawner`. Tests use `DynamicSceneRoot` instead of using `SceneSpawner` directly and it works since it uses a bit different mechanism. I noticed this in my game and tested the fix.
1 parent 4a2ddc4 commit 132fb4d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/scene.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ fn add_outline(
4141
mut commands: Commands,
4242
mut query: Query<(&mut AsyncSceneInheritOutline, Option<&SceneInstance>)>,
4343
systems: Res<AsyncSceneInheritOutlineSystems>,
44-
scene_spawner: Res<SceneSpawner>,
44+
scene_spawner: Option<Res<SceneSpawner>>, // Could be temporarily removed from the world when a scene is spawning
4545
) {
4646
let Ok((mut scene_outline, scene_instance)) = query.get_mut(*entity_input) else {
4747
return;
4848
};
4949
let mut ready = false;
50-
if let Some(scene_instance) = scene_instance {
50+
if let (Some(scene_instance), Some(scene_spawner)) = (scene_instance, scene_spawner) {
5151
let iid = **scene_instance;
5252
if scene_spawner.instance_is_ready(iid) {
5353
for child in scene_spawner.iter_instance_entities(iid) {

0 commit comments

Comments
 (0)