Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets in folders with multi asset sources can only use primary source #10120

Closed
anarelion opened this issue Oct 14, 2023 · 0 comments · Fixed by #10121
Closed

Assets in folders with multi asset sources can only use primary source #10120

anarelion opened this issue Oct 14, 2023 · 0 comments · Fixed by #10121
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled

Comments

@anarelion
Copy link
Contributor

Bevy version

main (0.12), just after PR #9885 is committed

What you did

I have 2 sources, registered as follow

    app.register_asset_source(
        AssetSourceId::Default,
        AssetSource::build().with_reader(|| Box::new(FileAssetReader::new(ASSET_PATH))),
    );
    app.register_asset_source(
        AssetSourceId::Name("packfile".into()),
        AssetSource::build().with_reader(|| Box::new(PackFileReader::new(ASSET_PATH))),
    );

When I try to load a folder in the setup system.

fn setup(mut commands: Commands, assets: Res<AssetServer>) {
    commands.insert_resource(Handles {
        global_assets: assets.load_folder("packfile://global_assets.pak"),
    });
}

What went wrong

My PackFileReader considers pack files as a directory and starts reading the "directory" with read_directory and returns 1 file which is attempted to be loaded, eventually reaching this function

let source = self.get_source(asset_path.source())?;
. At that point path is global_assets.pak/internal_file.bmp and has lost the packfile:// and the source/reader resolves to the default one, not the packfile.

Additional information

Most of the AssetReader functions use Path and PathBuf instead of AssetPath, so it is easy to lose the source info

@anarelion anarelion added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 14, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 15, 2023
# Objective

Fixes #10120

## Solution

Assign the folder path source to loaded descendant asset paths in
`load_folder`
ameknite pushed a commit to ameknite/bevy that referenced this issue Nov 6, 2023
# Objective

Fixes bevyengine#10120

## Solution

Assign the folder path source to loaded descendant asset paths in
`load_folder`
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

Fixes bevyengine#10120

## Solution

Assign the folder path source to loaded descendant asset paths in
`load_folder`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant