Open kyrosle opened 3 days ago
Could you give an example of what you want your asset collection to look like?
In my earliest game development, I only considered one type of player assets. However, after wanting to add more player assets into my game, if I continue adding other player assets into the same GameAssets
structure, it will make the fields grow more and more, as shown in this code:
#[derive(AssetCollection, Resource)]
pub struct GameAssets {
// -- PLAYER ---
#[asset(texture_atlas(
tile_size_x = 80,
tile_size_y = 80,
columns = 23,
rows = 5
))]
pub player_layout: Handle<TextureAtlasLayout>,
#[asset(path = "player/player.png")]
pub player_sprite: Handle<Image>,
#[asset(
paths(
"player/player.trickfilm#idle",
"player/player.trickfilm#moving",
"player/player.trickfilm#dashing",
"player/player.trickfilm#hooking",
"player/player.trickfilm#sliding",
),
collection(typed)
)]
pub player_animations: Vec<Handle<AnimationClip2D>>,
#[asset(texture_atlas(
tile_size_x = 192,
tile_size_y = 192,
columns = 10,
rows = 23,
))]
pub player02_layout: Handle<TextureAtlasLayout>,
#[asset(path = "player/player02.png")]
pub player02_sprite: Handle<Image>,
#[asset(
paths(
"player/player02.trickfilm#heal",
"player/player02.trickfilm#defence",
"player/player02.trickfilm#flames",
"player/player02.trickfilm#buff",
),
collection(typed)
)]
pub player02_animations: Vec<Handle<AnimationClip2D>>,
Can I put some related resource content into a structure, and then use fields to store it in GameStore
(using like assets.player_module.player_sprite
), while also being able to use macros?
There is no support for nested asset collections at the moment. In this case, I would prefer to split your collection by "domain". Why not create an AssetCollection
PlayerAssets
? You can load any number of asset collections in a loading state.
now i put all assets hanndlers in a struct
GameAssets
, can i split to the corresponding module's assets mod?