Make SceneSpawner::spawn_dynamic
return the spawned scene's InstanceId
#6661
Labels
A-Scenes
Serialized ECS data stored on the disk
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
Currently,
SceneSpawner::spawn_dynamic
returns unit (()
) rather than the spawned scene'sInstanceId
.It is difficult to work with any
DynamicScene
that is spawned this way, because the lack of anInstanceId
makes it impossible to do things such as iterating over the scene's entities usingSceneSpawner::iter_instance_entities
or checking if it's ready usingSceneSpawner::is_instance_ready
:It also makes the API inconsistent, since every other method in
SceneSpawner
returns anInstanceId
in some form, including otherDynamicScene
-spawning methods such asSceneSpawner::spawn_dynamic_as_child
:What solution would you like?
Change
spawn_dynamic
's return type toInstanceId
and return the spawned scene'sInstanceId
:What alternative(s) have you considered?
A possible workaround would be to go through multiple steps to transform a
Handle<DynamicScene>
to aHandle<Scene>
, with the help ofRes<Assets<DynamicScene>>
,Scene::from_dynamic_scene
, andResMut<Assets<Scene>>
.This adds unnecessary complexity and is not very elegant, but is unfortunately the only solution for those who do not want to spawn the
DynamicScene
as a child of another entity, and want to do something with the scene'sInstanceId
.The text was updated successfully, but these errors were encountered: