jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.19k stars 173 forks source link

Any way to make the inspector way toggleable with a keypress? #49

Closed stevenliebregt closed 2 years ago

stevenliebregt commented 2 years ago

Couldn't find any info on this, is it possible to toggle the window using a keypress?

jakobhellermann commented 2 years ago

If you're using the world inspector, you can set the enabled boolean when a key is pressed in a system, something like

fn toggle_inspector(input: Res<Input<KeyCode>>, world_inspector_params: ResMut<WorldInspectorParams>) {
  if input.just_pressed(KeyCode::Escape) {
    world_inspector.params.enabled = !world_inspector_params.enabled;
  }
}
stevenliebregt commented 2 years ago

Brilliant! Thanks so much, I'm quite new to Bevy so I hadn't figured out that I could use that resource.