Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow loading assets with custom async behavior (#13700)
# 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`
- Loading branch information