Skip to content

Conversation

@tim-blackbird
Copy link

@tim-blackbird tim-blackbird commented Aug 5, 2025

Calling spawn_scene from a template like this does not spawn the scene.

commands.spawn_scene(bsn!(template(|entity| {
    entity.world_scope(|world| {
        world.spawn_scene(bsn! (...));
    });
    Ok(())
})));

The call to world.spawn_scene ends up happening within spawn_queued and therefore the inserted ScenePatchInstance component never matches the Added<ScenePatchInstance> filter of the system, and so the scene is never spawned.

Instead of the Added filter, this PR adds the NewScenes resource to store newly queued scene spawns. It is populated via an On<Add, ScenePatchInstance> observer.
Then, within spawn_queued we also loop until no more new scenes are produced by the calls to scene.spawn to avoid delaying 'nested' scene spawns until the next frame, or even later

And I could not resist changing the event reading portion to use let chains :)

@cart cart merged commit 05b79c2 into cart:next-gen-scenes Aug 10, 2025
cart pushed a commit that referenced this pull request Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants