Reputation: 39
I have a script that recognizes swiping input. When I now start a swipe, it also triggers Input.GetMouseButtonDown(0)
. Can you tell me how to delete Input.GetMouseButtonDown(0)
that comes from the swipe?
With that swipe the game gets paused. (with Time.timeScale = 0f;
)
After resume, the action which was triggered from Input.GetMouseButtonDown(0)
before pausing the game goes on.
My Ideas: Work with TouchPhase.Stationary
or look for short tap?
Upvotes: 0
Views: 190
Reputation: 830
I would recommend not using Input class at all, it causes many problems, better have separate RaycastTarget on UI with Script implementing IPointerDownHandler, IPointerUpHandler, that will ensure only one RaycastTarget at the moment is handling your touches. Input.GetMouseButton will return true even if some RaycastTarget already should have consumed your events.
Upvotes: 0
Reputation: 1866
Off the top of my head, you can either:
Input.ResetInputAxes
; it will clear all input flags for one frame.Input.GetMouseButtonDown(0)
elsewhere.Both will require ensuring that the swipe detection happens before you check for Input.GetMouseButtonDown(0)
.
One way of ensuring it, is by using Unity's script execution order settings.
Upvotes: 1