No convenient way to set default assets through the `AssetServer`
- 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, it seems like the simplest way to set the default value of an `Assets` collection is this:
```rust
fn load_default_font(mut fonts: ResMut>) {
let bytes = include_bytes!("font.ttf");
let font = Font::try_from_bytes(bytes.to_vec()).unwrap();
fonts.insert(AssetId::::DEFAULT_UUID, font);
}
```
This sidesteps the whole asset system, and requires including potentially large data in the binary (in my case, a 14 MiB font file), so it's not ideal.
`AssetServer` has no methods that load an asset into an existing `Handle`/`AssetId`, so it cannot directly be used for this. It's possible to load the asset with a different `Handle`, listen to the asset event that indicates it has loaded, and then copy the asset over to the default ID. This is extremely inconvenient, though.
## What solution would you like?
`AssetServer` should expose some way of asynchronously loading an asset into an existing `Handle` or `AssetId`, overwriting whatever is already there.
## What alternative(s) have you considered?
None so far. Open to suggestions.
Contributor guide
Assessment
This issue has not been assessed yet.