bevy/crates/bevy_asset/src
Nicola Papale f7f7e326e5
Add methods to directly load assets from World (#12023)
# Objective

`FromWorld` is often used to group loading and creation of assets for
resources.

With this setup, users often end up repetitively calling
`.resource::<AssetServer>` and `.resource_mut::<Assets<T>>`, and may
have difficulties handling lifetimes of the returned references.

## Solution

Add extension methods to `World` to add and load assets, through a new
extension trait defined in `bevy_asset`.

### Other considerations

* This might be a bit too "magic", as it makes implicit the resource
access.
* We could also implement `DirectAssetAccessExt` on `App`, but it didn't
feel necessary, as `FromWorld` is the principal use-case here.

---

## Changelog

* Add the `DirectAssetAccessExt` trait, which adds the `add_asset`,
`load_asset` and `load_asset_with_settings` method to the `World` type.
2024-02-27 00:28:26 +00:00
..
io Use immutable key for HashMap and HashSet (#12086) 2024-02-26 16:27:40 +00:00
processor Use immutable key for HashMap and HashSet (#12086) 2024-02-26 16:27:40 +00:00
server Use immutable key for HashMap and HashSet (#12086) 2024-02-26 16:27:40 +00:00
assets.rs Add to_bits and from_bits functions to AssetIndex (#12127) 2024-02-26 21:02:26 +00:00
direct_access_ext.rs Add methods to directly load assets from World (#12023) 2024-02-27 00:28:26 +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 methods to directly load assets from World (#12023) 2024-02-27 00:28:26 +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 Normalise root path in file_watcher (#12102) 2024-02-25 15:21:06 +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