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

Batch loading multiple assets with naming patterns #200

Open
wentao opened this issue Feb 25, 2024 · 0 comments
Open

Batch loading multiple assets with naming patterns #200

wentao opened this issue Feb 25, 2024 · 0 comments

Comments

@wentao
Copy link

wentao commented Feb 25, 2024

There is the use case: I have a GLB file containing multiple animations named as

filename.glb#Animation{i}

where i starts with 0 and keeps incrementing. For example, if the glb file has 30 animations then in order to load them into a Vec, we have to do something like

#[derive(AssetCollection, Resource)]
pub struct Animations {
    #[asset(
        paths(
            "models/explosion.glb#Animation0",
            "models/explosion.glb#Animation1",
            "models/explosion.glb#Animation2",
            "models/explosion.glb#Animation3",
            "models/explosion.glb#Animation4",
            "models/explosion.glb#Animation5",
            "models/explosion.glb#Animation6",
            "models/explosion.glb#Animation7",
            "models/explosion.glb#Animation8",
            "models/explosion.glb#Animation9",
            "models/explosion.glb#Animation10",
            "models/explosion.glb#Animation11",
            "models/explosion.glb#Animation12",
            "models/explosion.glb#Animation13",
            "models/explosion.glb#Animation14",
            "models/explosion.glb#Animation15",
            "models/explosion.glb#Animation16",
            "models/explosion.glb#Animation17",
            "models/explosion.glb#Animation18",
            "models/explosion.glb#Animation19",
            "models/explosion.glb#Animation20",
            "models/explosion.glb#Animation21",
            "models/explosion.glb#Animation22",
            "models/explosion.glb#Animation23",
            "models/explosion.glb#Animation24",
            "models/explosion.glb#Animation25",
            "models/explosion.glb#Animation26",
            "models/explosion.glb#Animation27",
            "models/explosion.glb#Animation28",
            "models/explosion.glb#Animation29",
        ),
        collection(typed)
    )]
    pub explosion: Vec<Handle<AnimationClip>>,
}

This works, but it's very tedious and error prone to manually constructs the paths array.

It would be great if we can add some path_pattern support. Maybe something like the following
#[asset(paths_pattern("filename.glb#Animation{}", 0..30), collection(typed)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant