Skip to content

Commit

Permalink
Fix TouchSticks with parents in the hierarchy (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellzbellz123 authored Nov 24, 2023
1 parent 64b237d commit 3b1f97f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,16 @@ impl<S: Hash + Sync + Send + Clone + Default + Reflect + FromReflect + TypePath
}

fn map_input_zones_from_ui_nodes<S: StickIdType>(
interaction_areas: Query<(&Transform, &Node), With<TouchStickInteractionArea>>,
mut sticks: Query<&mut TouchStick<S>>,
mut interaction_areas: Query<
(&mut TouchStick<S>, &GlobalTransform, &Node),
With<TouchStickInteractionArea>,
>,
) {
for (transform, node) in &interaction_areas {
// todo: match stick ids!

let pos = transform.translation.truncate();
for (mut touch_stick, transform, node) in &mut interaction_areas {
let pos = transform.translation().truncate();
let size = node.size();
let interaction_area = Rect::from_center_size(pos, size);

for mut stick in sticks.iter_mut() {
stick.interactable_zone = interaction_area;
}
touch_stick.interactable_zone = interaction_area;
}
}

Expand Down

0 comments on commit 3b1f97f

Please sign in to comment.