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

Array syntax in RON dynamic collections? #78

Open
inodentry opened this issue Aug 4, 2022 · 1 comment · May be fixed by #151
Open

Array syntax in RON dynamic collections? #78

inodentry opened this issue Aug 4, 2022 · 1 comment · May be fixed by #151

Comments

@inodentry
Copy link
Contributor

Would it be possible to do something like this?

#[derive(AssetCollection)]
struct SpriteAnimationSequences {
    // maybe this needs a new attribute?
    // `collection(array)` or something,
    // to distinguish from `Files`
    #[asset(key = "anim.jumps", collection(typed)]
    jumps: Vec<Handle<TextureAtlas>>,
}
({
    // just use RON "array syntax"
    // to list as many items as we need
    "anim.jumps": [
        TextureAtlas (
            path: "jump_long.png",
            tile_size_x: 24.,
            tile_size_y: 32.,
            columns: 16,
            rows: 1,
        ),
        TextureAtlas (
            path: "jump_med.png",
            tile_size_x: 24.,
            tile_size_y: 32.,
            columns: 12,
            rows: 1,
        ),
        TextureAtlas (
            path: "jump_short.png",
            tile_size_x: 24.,
            tile_size_y: 32.,
            columns: 8,
            rows: 1,
        ),
    ],
})
@NiklasEi
Copy link
Owner

NiklasEi commented Aug 8, 2022

I thought this would be easily implemented using an untagged enum with a Single and a Vec variant. But I ran into ron-rs/ron#217.

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

Successfully merging a pull request may close this issue.

2 participants