Is there a simple way for detecting double click on images in the UI in Unity 5? Or can it be only done by counting time between clicks?
My question is for a project made for mobile devices.
Is there a simple way for detecting double click on images in the UI in Unity 5? Or can it be only done by counting time between clicks?
My question is for a project made for mobile devices.
Attach it to GameObject you want to handle double click :
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;
public class DoubleClick : MonoBehaviour, IPointerDownHandler
{
public void OnPointerDown (PointerEventData eventData)
{
if(eventData.clickCount == 2){
Debug.Log ("Double Click");
eventData.clickCount = 0;
}
}
}