mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Fixes potential panic when unwrapping touch event on Moved phase (#1591)
Should fix https://github.com/bevyengine/bevy/issues/1516. I don't have any devices available to test this tbh but I feel like this was the only spot that could be causing a panic. @ptircylinder since you posted this issue, could you please try to run the example on this branch and check if you get the same behavior while using your device? Thank you!
This commit is contained in:
parent
faeccd7a09
commit
e9a501e6b8
1 changed files with 7 additions and 6 deletions
|
@ -194,12 +194,13 @@ impl Touches {
|
||||||
self.just_pressed.insert(event.id, event.into());
|
self.just_pressed.insert(event.id, event.into());
|
||||||
}
|
}
|
||||||
TouchPhase::Moved => {
|
TouchPhase::Moved => {
|
||||||
let mut new_touch = self.pressed.get(&event.id).cloned().unwrap();
|
if let Some(mut new_touch) = self.pressed.get(&event.id).cloned() {
|
||||||
new_touch.previous_position = new_touch.position;
|
new_touch.previous_position = new_touch.position;
|
||||||
new_touch.previous_force = new_touch.force;
|
new_touch.previous_force = new_touch.force;
|
||||||
new_touch.position = event.position;
|
new_touch.position = event.position;
|
||||||
new_touch.force = event.force;
|
new_touch.force = event.force;
|
||||||
self.pressed.insert(event.id, new_touch);
|
self.pressed.insert(event.id, new_touch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TouchPhase::Ended => {
|
TouchPhase::Ended => {
|
||||||
self.just_released.insert(event.id, event.into());
|
self.just_released.insert(event.id, event.into());
|
||||||
|
|
Loading…
Reference in a new issue