Skip to content

Commit a138804

Browse files
committed
Add reload_asset method to AssetServer. (#5106)
# Objective Add support for custom `AssetIo` implementations to trigger reloading of an asset. ## Solution - Add a public method to `AssetServer` to allow forcing the reloading of an asset. --- ## Changelog - Add method `reload_asset` to `AssetServer`. Co-authored-by: Robert G. Jakabosky <[email protected]>
1 parent a32eac8 commit a138804

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/bevy_asset/src/asset_server.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ impl AssetServer {
371371
self.get_handle_untyped(handle_id)
372372
}
373373

374+
/// Force an [`Asset`] to be reloaded.
375+
///
376+
/// This is useful for custom hot-reloading or for supporting `watch_for_changes`
377+
/// in custom [`AssetIo`] implementations.
378+
pub fn reload_asset<'a, P: Into<AssetPath<'a>>>(&self, path: P) {
379+
self.load_untracked(path.into(), true);
380+
}
381+
374382
pub(crate) fn load_untracked(&self, asset_path: AssetPath<'_>, force: bool) -> HandleId {
375383
let server = self.clone();
376384
let owned_path = asset_path.to_owned();

0 commit comments

Comments
 (0)