Skip to content

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

@anarelion

Description

@anarelion

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions