From b6f825968b9a39d709a47d2c22bc6f07df74eafe Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Sat, 22 Apr 2023 23:38:46 -0700 Subject: [PATCH] Add LoadContext::get_handle_untyped --- crates/bevy_asset/src/loader.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 2b76edadf8434..55611b6a1803a 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -1,6 +1,6 @@ use crate::{ path::AssetPath, AssetIo, AssetIoError, AssetMeta, AssetServer, Assets, Handle, HandleId, - RefChangeChannel, + HandleUntyped, RefChangeChannel, }; use anyhow::Error; use anyhow::Result; @@ -166,11 +166,16 @@ impl<'a> LoadContext<'a> { self.get_handle(AssetPath::new_ref(self.path(), Some(label))) } - /// Gets a handle to an asset of type `T` from its id. + /// Gets a strong handle to an asset of type `T` from its id. pub fn get_handle, T: Asset>(&self, id: I) -> Handle { Handle::strong(id.into(), self.ref_change_channel.sender.clone()) } + /// Gets an untyped strong handle for an asset with the provided id. + pub fn get_handle_untyped>(&self, id: I) -> HandleUntyped { + HandleUntyped::strong(id.into(), self.ref_change_channel.sender.clone()) + } + /// Reads the contents of the file at the specified path through the [`AssetIo`] associated /// with this context. pub async fn read_asset_bytes>(&self, path: P) -> Result, AssetIoError> {