diff --git a/crates/bevy_ui/src/picking_backend.rs b/crates/bevy_ui/src/picking_backend.rs index d3ef8abd80d0f..90d1c4567b205 100644 --- a/crates/bevy_ui/src/picking_backend.rs +++ b/crates/bevy_ui/src/picking_backend.rs @@ -143,7 +143,8 @@ pub fn ui_picking( } // The list of node entities hovered for each (camera, pointer) combo - let mut hit_nodes = HashMap::<(Entity, PointerId), Vec<(Entity, Vec2)>>::default(); + let mut hit_nodes = + HashMap::<(Entity, PointerId), Vec<(Entity, Entity, Option, Vec2)>>::default(); // prepare an iterator that contains all the nodes that have the cursor in their rect, // from the top node to the bottom one. this will also reset the interaction to `None` @@ -210,6 +211,8 @@ pub fn ui_picking( .or_default() .push(( node_entity, + camera_entity, + node.pickable.cloned(), node.transform.inverse().transform_point2(*cursor_position) / node.node.size(), )); @@ -224,19 +227,13 @@ pub fn ui_picking( let mut picks = Vec::new(); let mut depth = 0.0; - for (hovered_node, position) in hovered { - let node = node_query.get(*hovered_node).unwrap(); - - let Some(camera_entity) = node.target_camera.get() else { - continue; - }; - + for (hovered_node, camera_entity, pickable, position) in hovered { picks.push(( - node.entity, - HitData::new(camera_entity, depth, Some(position.extend(0.0)), None), + *hovered_node, + HitData::new(*camera_entity, depth, Some(position.extend(0.0)), None), )); - if let Some(pickable) = node.pickable { + if let Some(pickable) = pickable { // If an entity has a `Pickable` component, we will use that as the source of truth. if pickable.should_block_lower { break;