jakobhellermann / bevy-inspector-egui

Inspector plugin for the bevy game engine
Apache License 2.0
1.12k stars 166 forks source link

Is there a way to get the Window Size/Position created by InspectorPlugin? #108

Closed cole21771 closed 1 year ago

cole21771 commented 1 year ago

A part of my game involves doing something on clicking anywhere in the game.

However, clicks on the egui inspector window count as clicks in the game and are caught by my clicking system. I'd love to find a way to exclude clicks within the window from getting picked up by that system.

I thought maybe I could get the coordinates of the window and it's size and do some filtering myself with basic math, but I haven't been able to find a way to get the egui window coords or window size created by the InspectorPlugin. Am I missing something or is there no way to get that data?

jakobhellermann commented 1 year ago

You can use is_pointer_over_area to see if the pointer is over any egui window. https://github.com/aevyrie/bevy_mod_picking/blob/554649a951689dce66d0d759839b326874e8826f/backends/bevy_picking_egui/src/lib.rs#L72

cole21771 commented 1 year ago

Thank you! That worked exactly as I had hoped with this simple code

let hovering_over_egui = egui_context.ctx_for_window_mut(WindowId::default()).is_pointer_over_area();