Custom System Params
Bevy version: 0.13Last updated:
We can reduce the argument counts and control access to our queries by making custom SystemParam
. A system param is valid as long as each field of its struct is also a SystemParam
like a Query
, Resource
, etc.
Its easy to do this using the #[derive(SystemParam)]
#[derive(SystemParam)]
struct SizeParams<'w, 's> {
images: ResMut<'w, Assets<Image>>,
primary_window_query: Query<'w, 's, &'static Window, With<PrimaryWindow>>,
windows_query: Query<'w, 's, &'static Window>,
}
fn print_image_sizes(sizes: SizeParams) {
for image in sizes.images {
// ...
}
}