mvlabat / bevy_egui

This crate provides an Egui integration for the Bevy game engine. 🇺🇦 Please support the Ukrainian army: https://savelife.in.ua/en/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add run condition for whether egui is using pointer input

jakobhellermann opened this issue · comments

It came up in jakobhellermann/bevy-inspector-egui#147 that it is often useful to run some systems (like looking around) only if egui is not using the pointer input.

mod common_conditions {
  fn egui_mouse_unused(egui_contexts: Query<&EguiContext>) -> bool {
      egui_contexts
          .iter()
          .all(|ctx| !ctx.get().wants_pointer_input())
  }
}
app.add_systems(
    Update,
    (camera_pan, camera_zoom).run_if(bevy_egui::common_conditions::mouse_pointer_valid()),
)

For prior art, bevy also has some common_conditions for various subcrates: