Path: blob/main/release-content/release-notes/asset_saving.md
9309 views
------Since Bevy 0.12, we've had the AssetSaver trait. Unfortunately, this trait was not really usable for asset saving: it was only intended for use with asset processing! This was a common stumbling block for users, and pointed to a gap in our API.
Now, users can save their assets using save_using_saver. To use this involves two steps.
1. Building the SavedAsset
To build the SavedAsset, either use SavedAsset::from_asset:
Or for more complicated cases, SavedAssetBuilder:
Note that since these assets are borrowed, building the SavedAsset should happen in the same async task as the next step.
2. Calling save_using_saver
Now, with a SavedAsset, we can just call save_using_saver and fill in any arguments:
Part of this includes implementing the AssetSaver trait on MyAssetSaver. In addition, this is an async function, so it is likely you will want to spawn this using IoTaskPool::get().spawn(...).