Open bananaturtlesandwich opened 1 month ago
this can be done manually as well for now
impl AssetCollection for MyAssets {
fn create(world: &mut World) -> Self {
world.resource_scope(|world, _: Mut<DynamicAssets>| MyAssets {
files_typed: {
let asset_server = world
.get_resource::<AssetServer>()
.expect("Cannot get AssetServer");
[
asset_server.load("images/player.png"),
asset_server.load("images/tree.png"),
]
},
})
}
fn load(world: &mut World) -> Vec<UntypedHandle> {
let cell = world.cell();
let asset_server = cell
.get_resource::<AssetServer>()
.expect("Cannot get AssetServer");
vec![
asset_server
.load_untyped("images/player.png")
.untyped(),
asset_server
.load_untyped("images/tree.png")
.untyped(),
]
}
}
as shown in this example in the readme
you can load collections as vectors but this can be a bit of a waste if you don't intend to mutate the resource (which i assume is the typical use case) so being able to do this as
would be great but implementation would probably need a lot of work