check if the egui context wants pointer focus, disable orbit camera if so. this disables egui interactions being sent to the orbital camera

This commit is contained in:
rezural
2021-05-29 13:00:01 +10:00
parent 3bac79ecac
commit a49605bd9b

View File

@@ -423,6 +423,7 @@ impl TestbedApp {
.insert_non_send_resource(self.plugins)
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
.add_system_to_stage("physics", update_testbed.system())
.add_system(egui_focus.system())
.run();
}
}
@@ -841,6 +842,16 @@ fn setup_graphics_environment(mut commands: Commands) {
});
}
fn egui_focus(ui_context: Res<EguiContext>, mut cameras: Query<&mut OrbitCamera>) {
let mut camera_enabled = true;
if ui_context.ctx().wants_pointer_input() {
camera_enabled = false;
}
for mut camera in cameras.iter_mut() {
camera.enabled = camera_enabled;
}
}
fn update_testbed(
mut commands: Commands,
windows: Res<Windows>,