mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
1f61c26d2e
# Objective `Scene` and `DynamicScene` work with `InstanceInfo` at different levels of abstraction - `Scene::write_to_world_with` returns an `InstanceInfo` whereas `DynamicScene::write_to_world_with` returns `()`. Instances are created one level higher at the `SceneSpawner` API level. - `DynamicScene::write_to_world_with` takes the `entity_map` as an argument whereas the `Scene` version is less flexible and creates a new one for you. No reason this needs to be the case. ## Solution I propose changing `Scene::write_to_world_with` to match the API we have for `DynamicScene`. Returning the `InstanceInfo` as we do today just seems like a leaky abstraction - it's only used in `spawn_sync_internal`. Being able to pass in an entity_map gives you more flexibility with how you write entities to a world. This also moves `InstanceInfo` out of `Scene` which is cleaner conceptually. If someone wants to work with instances then they should work with `SceneSpawner` - I see `write_to_world_with` as a lower-level API to be used with exclusive world access. ## Testing Code is just shifting things around. ## Changelog Changed `Scene::write_to_world_with` to take `entity_map` as an argument and no longer return an `InstanceInfo` ## Migration Guide `Scene::write_to_world_with` no longer returns an `InstanceInfo`. Before ```rust scene.write_to_world_with(world, ®istry) ``` After ```rust let mut entity_map = EntityHashMap::default(); scene.write_to_world_with(world, &mut entity_map, ®istry) ``` |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_color | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_dev_tools | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_state | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |