bevy/crates/bevy_scene/src
Ricky Taylor 0f20cfaa57
Only attempt to copy resources that still exist from scenes (#9984)
# Objective

Avert a panic when removing resources from Scenes.

### Reproduction Steps
```rust
let mut scene = Scene::new(World::default());
scene.world.init_resource::<Time>();
scene.world.remove_resource::<Time>();
scene.clone_with(&app.resource::<AppTypeRegistry>());
```

### Panic Message
```
thread 'Compute Task Pool (10)' panicked at 'Requested resource bevy_time::time::Time does not exist in the `World`. 
                Did you forget to add it using `app.insert_resource` / `app.init_resource`? 
                Resources are also implicitly added via `app.add_event`,
                and can be added by plugins.', .../bevy/crates/bevy_ecs/src/reflect/resource.rs:203:52

```

## Solution

Check that the resource actually still exists before copying.

---

## Changelog

- resolved a panic caused by removing resources from scenes
2023-10-02 00:05:36 +00:00
..
bundle.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00
dynamic_scene_builder.rs bevy_scene: Add SceneFilter (#6793) 2023-07-06 21:04:26 +00:00
dynamic_scene.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00
lib.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00
scene_filter.rs bevy_scene: Add SceneFilter (#6793) 2023-07-06 21:04:26 +00:00
scene_loader.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00
scene_spawner.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00
scene.rs Only attempt to copy resources that still exist from scenes (#9984) 2023-10-02 00:05:36 +00:00
serde.rs Finish documenting bevy_scene (#9949) 2023-10-01 17:54:19 +00:00