bevy
bevy copied to clipboard
Fix PickingInteraction change detection
Objective
Fixes #19464
Solution
Instead of clearing previous PickingInteractions before updating, we clear them last for those components that weren't updated, and use set_if_neq when writing.
Testing
I tried the sprite_picking example and it still works.
You can add the following system to picking examples to check that change detection works as intended:
fn print_picking(query: Query<(Entity, &PickingInteraction), Changed<PickingInteraction>>) {
for (entity, interaction) in &query {
println!("{entity} {interaction:?}");
}
}