Skip to content

Commit

Permalink
fix load_internal_binary_asset with debug_asset_server (bevyengine#7246)
Browse files Browse the repository at this point in the history
# 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`
  • Loading branch information
IceSentry authored and alradish committed Jan 22, 2023
1 parent 4ef9d6b commit 2612917
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/debug_asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2612917

Please sign in to comment.