Merge pull request #193 from rezural/egui-focus
Testbed: check if the egui context wants pointer focus, disable orbit camera if so.
This commit is contained in:
@@ -423,6 +423,7 @@ impl TestbedApp {
|
|||||||
.insert_non_send_resource(self.plugins)
|
.insert_non_send_resource(self.plugins)
|
||||||
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
.add_stage_before(CoreStage::Update, "physics", SystemStage::single_threaded())
|
||||||
.add_system_to_stage("physics", update_testbed.system())
|
.add_system_to_stage("physics", update_testbed.system())
|
||||||
|
.add_system(egui_focus.system())
|
||||||
.run();
|
.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(
|
fn update_testbed(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
windows: Res<Windows>,
|
windows: Res<Windows>,
|
||||||
|
|||||||
Reference in New Issue
Block a user