diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index a30099197e9b2..4fc451991bbfb 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -5,8 +5,8 @@ use crate::{ Settings, }, path::AssetPath, - Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId, - UntypedHandle, + Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, LoadedUntypedAsset, + UntypedAssetId, UntypedHandle, }; use bevy_ecs::world::World; use bevy_utils::{BoxedFuture, CowArc, HashMap, HashSet}; @@ -462,6 +462,21 @@ impl<'a> LoadContext<'a> { handle } + /// Retrieves a handle for the asset at the given path and adds that path as a dependency of the asset without knowing its type. + pub fn load_untyped<'b>( + &mut self, + path: impl Into>, + ) -> Handle { + let path = path.into().to_owned(); + let handle = if self.should_load_dependencies { + self.asset_server.load_untyped(path) + } else { + self.asset_server.get_or_create_path_handle(path, None) + }; + self.dependencies.insert(handle.id().untyped()); + handle + } + /// Loads the [`Asset`] of type `A` at the given `path` with the given [`AssetLoader::Settings`] settings `S`. This is a "deferred" /// load. If the settings type `S` does not match the settings expected by `A`'s asset loader, an error will be printed to the log /// and the asset load will fail.