bevy-inspector-egui
bevy-inspector-egui copied to clipboard
Feat: egui mouse check
Added a resource which tracks wether mouse pointer should be handled the egui or Bevy's running systems. This gets rid of annoyance where one drags the egui window around (or scrolls through it) and that input is picked up by the Bevy's systems as a normal user input.
This could potentially be in Bevy's common input conditions, however it is not really common since it only occurrs when integrating with other Plugins.
Although this is simply a difference of how the inspector is integrated, I still put it under the quick examples, since it is strictly an upgrade from World Inspector example and is not really on the level of other integrations examples.
Only works for primary window.
cc @jakobhellermann
Thanks for the PR and sorry for leaving this unread for so long.
Is there a reason this should be a Plugin instead of having the run condition directly ask the EguiContext like
fn egui_mouse_free(egui_contexts: Query<&EguiContext>) -> bool {
egui_contexts
.iter()
.all(|ctx| !ctx.get().wants_pointer_input())
}
// or
fn egui_mouse_free<W: Component>(egui_contexts: Query<&EguiContext, With<W>>) -> bool {
let ctx = egui_contexts.single().get();
!ctx.wants_pointer_input()
}
?
I'd like to keep the amount of boilerplate required as minimal as possible.
I think this would fit very nicely in bevy_egui itself, I opened an issue upstream: https://github.com/mvlabat/bevy_egui/issues/218
Thanks for the PR and sorry for leaving this unread for so long.
Is there a reason this should be a
Plugininstead of having the run condition directly ask theEguiContextlikefn egui_mouse_free(egui_contexts: Query<&EguiContext>) -> bool { egui_contexts .iter() .all(|ctx| !ctx.get().wants_pointer_input()) } // or fn egui_mouse_free<W: Component>(egui_contexts: Query<&EguiContext, With<W>>) -> bool { let ctx = egui_contexts.single().get(); !ctx.wants_pointer_input() }?
I'd like to keep the amount of boilerplate required as minimal as possible.
There is no real reason as to why this should be a Plugin. I only did it because I thought it is cleaner that way, but then again I'm somewhat new to bevy. Doing it with just a function is indeed less boilerplate, so let's do it that way.