diff --git a/README.md b/README.md index 9d5567c..b8bc64d 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Now when you load files with the `.libgdx.atlas` extension through the asset ser > [!TIP] > Run `cargo run --example animation` to see this example for yourself! +Additionally, `AssetSource` are also supported (such as embedded assets) — just make sure that the `.libgdx.atlas` and `.png` files are located in the same path. + ## Contributing [See our CONTRIBUTING.md](/CONTRIBUTING.md) diff --git a/src/loader.rs b/src/loader.rs index 0a037bd..d607ed4 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -1,5 +1,5 @@ use bevy::{ - asset::{AssetLoader, AsyncReadExt}, + asset::{AssetLoader, AssetPath, AsyncReadExt}, platform::collections::HashMap, prelude::*, }; @@ -28,20 +28,26 @@ impl AssetLoader for LibGdxAtlasAssetLoader { let asset = AssetFile::new(file)?; - let path = load_context + let source = load_context + .asset_path() + .source() + .clone_owned(); + + let path: AssetPath = load_context .asset_path() .path() .parent() .ok_or(LibGdxAtlasAssetError::LoadingImageAsset( "can't find parent folder common to atlas and image asset".to_string(), ))? - .join(asset.file); + .join(asset.file) + .into(); let image: Image = load_context .loader() .immediate() .with_unknown_type() - .load(path) + .load(path.with_source(source)) .await? .take() .ok_or(LibGdxAtlasAssetError::LoadingImageAsset(