mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
9389de5c71
# Objective Currently, bevy supports custom asset loading via `AssetServer:;add`, which allows you to add arbitrary assets to the asset system and returns a handle to it. However this only works for assets that have already been fully loaded. If your loading logic involves any async, you need to wait until the asset is done loading before adding it to the server. This is problematic, as the `Handle` does not get allocated until the very end, which makes it very difficult to use and defeats the value of having handles for asynchronously-loaded assets. ## Solution Add the method `AssetServer::add_async`. This has the same behavior as `AssetServer::add`, only it accepts a future instead of a fully loaded asset. ## Testing I added an identical method to my company's fork of bevy, which works in our app. I'm not quite sure how to go about adding an actual unit test for asset loading behvior, but I will note that `AssetServer::add` also does not appear to have any tests. --- ## Changelog + Added `AssetServer::add_async`, which allows adding assets with custom asynchronous loading behavior to the `AssetServer` |
||
---|---|---|
.. | ||
macros | ||
src | ||
Cargo.toml | ||
README.md |