-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the
Children
component of the parent entity when a scene get…
…s deleted (#12710) # Objective - A scene usually gets created using the `SceneBundle` or `DynamicSceneBundle`. This means that the scene's entities get added as children of the root entity (the entity on which the `SceneBundle` gets added) - When the scene gets deleted using the `SceneSpawner`, the scene's entities are deleted, but the `Children` component of the root entity doesn't get updated. This means that the hierarchy becomes unsound, with Children linking to non-existing components. ## Solution - Update the `despawn_sync` logic to also update the `Children` from any parents of the scene, if there are any - Adds a test where a Scene gets despawned and checks for dangling Children references on the parent. The test fails on `main` but works here. ## Alternative implementations - One option could be to add a `parent: Option<Entity>` on the [InstanceInfo](https://github.com/bevyengine/bevy/blob/df15cd7dcc09869f7ce9c7865378591b91b31749/crates/bevy_scene/src/scene_spawner.rs#L27) struct that tracks if the SceneInstance was added as a child of a root entity
- Loading branch information
1 parent
bcdb20d
commit afff818
Showing
2 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters