@@ -41,13 +41,14 @@ fn add_outline(
4141 mut commands : Commands ,
4242 mut query : Query < ( & mut AsyncWorldInheritOutline , Option < & WorldInstance > ) > ,
4343 systems : Res < AsyncWorldInheritOutlineSystems > ,
44- world_spawner : Res < WorldInstanceSpawner > ,
44+ world_spawner : Option < Res < WorldInstanceSpawner > > ,
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+ // Assume that this scene cannot be ready if the SceneSpawner is currently in use.
51+ if let ( Some ( scene_instance) , Some ( world_spawner) ) = ( scene_instance, world_spawner) {
5152 let iid = * * scene_instance;
5253 if world_spawner. instance_is_ready ( iid) {
5354 for child in world_spawner. iter_instance_entities ( iid) {
@@ -240,4 +241,23 @@ mod tests {
240241 app. update ( ) ;
241242 assert_counts ( & mut app, 2 , 0 ) ;
242243 }
244+
245+ #[ test]
246+ fn test_add_when_scene_spawner_missing ( ) {
247+ let ( mut app, scene_entity) = setup ( ) ;
248+
249+ let scene_spawner = app
250+ . world_mut ( )
251+ . remove_resource :: < WorldInstanceSpawner > ( )
252+ . unwrap ( ) ;
253+ app. world_mut ( )
254+ . get_entity_mut ( scene_entity)
255+ . unwrap ( )
256+ . insert ( AsyncWorldInheritOutline :: default ( ) ) ;
257+ app. world_mut ( ) . flush ( ) ;
258+ app. world_mut ( ) . insert_resource ( scene_spawner) ;
259+
260+ app. update ( ) ;
261+ assert_counts ( & mut app, 0 , 2 ) ;
262+ }
243263}
0 commit comments