Impl FromWrold for Handle<T>
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
currently loading Handles from dynamic scenes loaded from a file will give you a weak handle. it would be nice if handles loaded this way were strong so that you don't have to keep a strong handle somewhere else to prevent assets from unloading that are in the scene. this would be necessary if we wanted to store asset dependency paths in scenes.
## What solution would you like?
1. Remove the Default implementation for Handle; use Handle::weak instead for this functionality
2. impl FromWrold for Handle; Access Asset so handle can be strong
3. Add set_id method that decrements the current id and increments the new id
## What alternative(s) have you considered?
This could also be done with the ReflectComponent implementation but would take significantly more work since that is (as far as I could tell) all auto-implemented with generics.
## Additional Info
it would also allow for a nice expansion of dynamic scenes when serialised we could add to the API
```rust
fn save_world(
world: &World,
asset_server: Res,
type_registry: Res,
) {
let scene = DynamicScene::from_world(world, &type_registry);
let ron = scene.serialize_ron_with_dependencys(&type_registry, &asset_server);
std::fs::write("./assets/scene.scn.ron", ron).unwrap();
}
```
this would require the asset server and extract any paths that the handles came from
Contributor guide
Assessment
This issue has not been assessed yet.