pub fn absorb_bevy_input_system(
egui_wants_input: Res<'_, EguiWantsInput>,
mouse_input: ResMut<'_, ButtonInput<MouseButton>>,
keyboard_input: ResMut<'_, ButtonInput<KeyCode>>,
keyboard_input_events: ResMut<'_, Events<KeyboardInput>>,
mouse_wheel_events: ResMut<'_, Events<MouseWheel>>,
mouse_button_input_events: ResMut<'_, Events<MouseButtonInput>>,
)
Expand description
Clears Bevy input event buffers and resets ButtonInput
resources if Egui
is using pointer or keyboard (see the write_egui_wants_input_system
run condition).
This system isn’t run by default, set EguiGlobalSettings::enable_absorb_bevy_input_system
to true
to enable it.
§Considerations
Enabling this system makes an assumption that bevy_egui
takes priority in input handling
over other plugins and systems. This should work ok as long as there’s no other system
clearing events the same way that might be in conflict with bevy_egui
, and there’s
no other system that needs a non-interrupted flow of events.
§Alternative
A safer alternative is to apply run_if(not(egui_wants_any_pointer_input))
or run_if(not(egui_wants_any_keyboard_input))
to your systems
that need to be disabled while Egui is using input (see the egui_wants_any_pointer_input
, egui_wants_any_keyboard_input
run conditions).