Skip to content

Commit c85d37d

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 c85d37d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_mod_outline"
33
version = "0.12.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT OR Apache-2.0"
66
description = "A mesh outlining plugin for Bevy."
77
readme = "README.md"

src/scene.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ 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) = scene_instance
51+
&& let Some(scene_spawner) = scene_spawner
52+
{
5153
let iid = **scene_instance;
5254
if scene_spawner.instance_is_ready(iid) {
5355
for child in scene_spawner.iter_instance_entities(iid) {

0 commit comments

Comments
 (0)