mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
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 <rjakabosky+neopallium@neoawareness.com>
This commit is contained in:
parent
a32eac825a
commit
a138804d61
1 changed files with 8 additions and 0 deletions
|
@ -371,6 +371,14 @@ impl AssetServer {
|
||||||
self.get_handle_untyped(handle_id)
|
self.get_handle_untyped(handle_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Force an [`Asset`] to be reloaded.
|
||||||
|
///
|
||||||
|
/// This is useful for custom hot-reloading or for supporting `watch_for_changes`
|
||||||
|
/// in custom [`AssetIo`] implementations.
|
||||||
|
pub fn reload_asset<'a, P: Into<AssetPath<'a>>>(&self, path: P) {
|
||||||
|
self.load_untracked(path.into(), true);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn load_untracked(&self, asset_path: AssetPath<'_>, force: bool) -> HandleId {
|
pub(crate) fn load_untracked(&self, asset_path: AssetPath<'_>, force: bool) -> HandleId {
|
||||||
let server = self.clone();
|
let server = self.clone();
|
||||||
let owned_path = asset_path.to_owned();
|
let owned_path = asset_path.to_owned();
|
||||||
|
|
Loading…
Reference in a new issue