diff --git a/CHANGELOG.md b/CHANGELOG.md index 58460f62..0e3a2db9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # UNRELEASED +- Added: support for touch inputs across multiple windows. - Changed: simplified debug settings and examples. Debug settings can be changed with the `DebugPickingMode` resource. - Fixed: replaced uses of `.insert` with `.try_insert`, where they could potentially panic. diff --git a/crates/bevy_picking_input/src/touch.rs b/crates/bevy_picking_input/src/touch.rs index 93dba830..e63ec37a 100644 --- a/crates/bevy_picking_input/src/touch.rs +++ b/crates/bevy_picking_input/src/touch.rs @@ -9,7 +9,7 @@ use bevy_utils::{ tracing::{debug, info}, HashMap, HashSet, }; -use bevy_window::{PrimaryWindow, Window, WindowRef}; +use bevy_window::{PrimaryWindow, WindowRef}; use bevy_picking_core::{ events::PointerCancel, @@ -24,7 +24,7 @@ use bevy_picking_core::{ pub fn touch_pick_events( // Input mut touches: EventReader, - windows: Query<(Entity, &Window), With>, + primary_window: Query>, // Local mut location_cache: Local>, // Output @@ -36,15 +36,12 @@ pub fn touch_pick_events( for touch in touches.read() { let pointer = PointerId::Touch(touch.id); let location = Location { - target: RenderTarget::Window(WindowRef::Primary) - .normalize(Some( - match windows.get_single() { - Ok(w) => w, - Err(_) => continue, - } - .0, - )) - .unwrap(), + target: match RenderTarget::Window(WindowRef::Entity(touch.window)) + .normalize(primary_window.get_single().ok()) + { + Some(target) => target, + None => continue, + }, position: touch.position, }; match touch.phase {