Skip to content

Emit an event when a scene has finished being spawned #2218

@szunami

Description

@szunami

What problem does this solve or what need does it fill?

Spawning a scene happens asynchronously and there isn't a pattern I know of to perform a callback when a scene finishes spawning. In my case, my scene contains a bunch of entities with Ground components; when the scene is done spawning, I want to add SpriteBundles to them.

What solution would you like?

Emit an event when a scene has finished spawning, roughly here: https://github.com/bevyengine/bevy/blob/main/crates/bevy_scene/src/scene_spawner.rs#L242

It is desirable that this event includes the InstanceId

What alternative(s) have you considered?

I currently have a workaround where I use a Query<&Ground, Without<Sprite>> and insert sprites whenever the scene finishes loading. This is no-op after the first time.

Additional context

I have talked this over with @TheRawMeatball & @alice-i-cecile in discord a bit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    Status

    Assets-wide Usability

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions