fix load_internal_binary_asset with debug_asset_server (#7246)

# Objective

- Enabling the `debug_asset_server` feature doesn't compile when using it with `load_internal_binary_asset!()`. The issue is because it assumes the loader takes an `&'static str` as a parameter, but binary assets loader expect `&'static [u8]`.

## Solution

- Add a generic type for the loader and use a different type in `load_internal_asset` and `load_internal_binary_asset`
This commit is contained in:
IceSentry 2023-01-18 02:07:26 +00:00
parent 0df67cdaae
commit 4ff50f6b50
2 changed files with 4 additions and 4 deletions

View File

@ -417,7 +417,7 @@ macro_rules! load_internal_asset {
let mut debug_app = $app
.world
.non_send_resource_mut::<$crate::debug_asset_server::DebugAssetApp>();
$crate::debug_asset_server::register_handle_with_loader(
$crate::debug_asset_server::register_handle_with_loader::<_, &'static str>(
$loader,
&mut debug_app,
$handle,
@ -455,7 +455,7 @@ macro_rules! load_internal_binary_asset {
let mut debug_app = $app
.world
.non_send_resource_mut::<$crate::debug_asset_server::DebugAssetApp>();
$crate::debug_asset_server::register_handle_with_loader(
$crate::debug_asset_server::register_handle_with_loader::<_, &'static [u8]>(
$loader,
&mut debug_app,
$handle,

View File

@ -116,8 +116,8 @@ pub(crate) fn sync_debug_assets<T: Asset + Clone>(
///
/// If this feels a bit odd ... that's because it is. This was built to improve the UX of the
/// `load_internal_asset` macro.
pub fn register_handle_with_loader<A: Asset>(
_loader: fn(&'static str) -> A,
pub fn register_handle_with_loader<A: Asset, T>(
_loader: fn(T) -> A,
app: &mut DebugAssetApp,
handle: HandleUntyped,
file_path: &str,