bevy/examples/window
François c6958b3056 add a SceneBundle to spawn a scene (#2424)
# Objective

- Spawning a scene is handled as a special case with a command `spawn_scene` that takes an handle but doesn't let you specify anything else. This is the only handle that works that way.
- Workaround for this have been to add the `spawn_scene` on `ChildBuilder` to be able to specify transform of parent, or to make the `SceneSpawner` available to be able to select entities from a scene by their instance id

## Solution

Add a bundle
```rust
pub struct SceneBundle {
    pub scene: Handle<Scene>,
    pub transform: Transform,
    pub global_transform: GlobalTransform,
    pub instance_id: Option<InstanceId>,
}
```

and instead of 
```rust
commands.spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0"));
```
you can do
```rust
commands.spawn_bundle(SceneBundle {
    scene: asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0"),
    ..Default::default()
});
```

The scene will be spawned as a child of the entity with the `SceneBundle`

~I would like to remove the command `spawn_scene` in favor of this bundle but didn't do it yet to get feedback first~

Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-06-09 20:34:09 +00:00
..
clear_color.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
low_power.rs use the default() method in examples instead of Default::default() (#4952) 2022-06-07 02:16:47 +00:00
multiple_windows.rs add a SceneBundle to spawn a scene (#2424) 2022-06-09 20:34:09 +00:00
scale_factor_override.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
transparent_window.rs Camera Driven Rendering (#4745) 2022-06-02 00:12:17 +00:00
window_settings.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00