- Home /
OnPointerDown PointerEventData clickCount not triggering on mobile device (touch)
I have a touch joystick for a mobile device. (works nicely) it uses PointEventData position to work. I'm trying to make it double press the joystick to boost. Works in editor on joysticks but only returns 0 for data.clickCount on mobile device even though the joystick works properly. I've got a gameobject with EventSystem, Standalone input module and touch input module(redundant apparently)
public virtual void OnPointerDown(PointerEventData data)
{
isPressed = true;
UpdateAxes(data.position);
if (data.clickCount == 2)
{
StartCoroutine(player.Boost());
}
}
Sounds likes a bug. I'm experiencing a similar issue on Android with touch - the click count is always 1. (Works fine in the editor...)
I too see this. Works correctly on Standalone and Editor, but not on iOS.
Answer by Xarbrough · Feb 20, 2017 at 11:01 AM
Apparently, this is not a bug, but intended (as stated by Unity QA). On Standalone we can use clickCount, but on mobile we have to manually count taps.
The two are not equivalent. clickCount is defined as "Number of clicks in a row" and should indicate the number of consecutive clicks (double click). touchCount, on the other hand, is defined as "Number of touches" and represents the number of concurrent touch points, i.e. the number of fingers touching the screen at the same time.
In other words, touchCount is no replacement for clickCount.
You are absolutely right, my original answer had an error. I was blindly repeating what I got back from Unity QA after submitting a bug report about the clickCount not working on iOS. So it looks like there is no equivalent method and we have to count mobile taps manually.
Your answer
Follow this Question
Related Questions
Count Number of Touches made in Android 2 Answers
How to make double buttons? 3 Answers
How to detect double click in c#? 5 Answers
Maintaining Run on direction change (double tap using GetAxis) 0 Answers
Touch Controls Event Triggers 1 Answer