bevy_asset_loader icon indicating copy to clipboard operation
bevy_asset_loader copied to clipboard

Array syntax in RON dynamic collections?

Open inodentry opened this issue 2 years ago • 1 comments

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,
        ),
    ],
})

inodentry avatar Aug 04 '22 17:08 inodentry

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.

NiklasEi avatar Aug 08 '22 10:08 NiklasEi