bevy/crates/bevy_asset/src
Nicola Papale 78b5e49202
Add a way to get a strong handle from an AssetId (#12088)
# Objective

- Sometimes, it is useful to get a `Handle<T>` from an `AssetId<T>`. For
example, when iterating `Assets` to find a specific asset. So much so
that it's possible to do so with `AssetServer::get_id_handle`
- However, `AssetServer::get_id_handle` doesn't work with assets
directly added to `Assets` using `Assets::add`.
- Fixes #12087

## Solution

- Add `Assets::get_strong_handle` to convert an `AssetId` into an
`Handle`
- Document `AssetServer::get_id_handle` to explain its limitation and
point to `get_strong_handle`.
- Add a test for `get_strong_handle`
- Add a `duplicate_handles` field to `Assets` to avoid dropping assets
with a live handle generated by `get_strong_handle` (more reference
counting yay…)
- Fix typos in `Assets` docs

---

## Changelog

- Add `Assets::get_strong_handle` to convert an `AssetId` into an
`Handle`
2024-02-25 15:20:03 +00:00
..
io Improve file watcher error msg (#12060) 2024-02-23 17:39:33 +00:00
processor Fix AssetTransformer breaking LabeledAssets (#11626) 2024-02-02 14:57:31 +00:00
server Add a way to get a strong handle from an AssetId (#12088) 2024-02-25 15:20:03 +00:00
assets.rs Add a way to get a strong handle from an AssetId (#12088) 2024-02-25 15:20:03 +00:00
event.rs Added AssetLoadFailedEvent, UntypedAssetLoadFailedEvent (#11369) 2024-01-17 21:12:00 +00:00
folder.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
handle.rs Add a way to get a strong handle from an AssetId (#12088) 2024-02-25 15:20:03 +00:00
id.rs bevy_reflect: Split #[reflect(where)] (#11597) 2024-01-29 17:54:17 +00:00
lib.rs Add a way to get a strong handle from an AssetId (#12088) 2024-02-25 15:20:03 +00:00
loader.rs Use Asset Path Extension for AssetLoader Disambiguation (#11644) 2024-02-12 15:44:55 +00:00
meta.rs Reorder impl to be the same as the trait (#11076) 2023-12-24 17:43:55 +00:00
path.rs fix some typos (#12038) 2024-02-22 18:55:22 +00:00
reflect.rs Enable the unsafe_op_in_unsafe_fn lint (#11591) 2024-01-28 23:18:11 +00:00
saver.rs Fix AssetTransformer breaking LabeledAssets (#11626) 2024-02-02 14:57:31 +00:00
transformer.rs fix some typos (#12038) 2024-02-22 18:55:22 +00:00