Created
May 13, 2022 11:47
-
-
Save tigregalis/d3c5afdde573abe07042cb74ac83207c to your computer and use it in GitHub Desktop.
bevy system for inspecting all entities and which components they have when pressing F1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::ecs::entity::Entities; | |
use bevy::ecs::archetype::Archetypes; | |
use bevy::ecs::component::Components; | |
fn inspect( | |
keyboard: Res<Input<KeyCode>>, | |
all_entities: Query<Entity>, | |
entities: &Entities, | |
archetypes: &Archetypes, | |
components: &Components, | |
) { | |
if keyboard.just_pressed(KeyCode::F1) { | |
for entity in all_entities.iter() { | |
println!("Entity: {:?}", entity); | |
if let Some(entity_location) = entities.get(entity) { | |
if let Some(archetype) = archetypes.get(entity_location.archetype_id) { | |
for component in archetype.components() { | |
if let Some(info) = components.get_info(component) { | |
println!(" {}", info.name()); | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment