| Bevy Version: | 0.13 | (outdated!) |
|---|
This entire book is outdated and no longer maintained. I am keeping it online, in case anyone still finds any of the information in it useful. To adapt to newer versions of Bevy, please consult Bevy's migration guides.
List All Resource Types
This example shows how to print a list of all types that have been added as resources.
fn print_resources(world: &World) {
let components = world.components();
let mut r: Vec<_> = world
.storages()
.resources
.iter()
.map(|(id, _)| components.get_info(id).unwrap())
.map(|info| info.name())
.collect();
// sort list alphebetically
r.sort();
r.iter().for_each(|name| println!("{}", name));
}
// print main world resources
app.add_systems(Last, print_resources);
// print render world resources
app.sub_app_mut(RenderApp)
.add_systems(Render, print_resources.in_set(RenderSet::Render));
It lists the types of all the resources that currently exist in your ECS World (by all registered plugins, your own, etc.).
Note that this does not give you a list of every type that is
useful as a resource. For that, you should consult API documentation,
looking for implementers of the Resource trait.