# Double Click Unity

Have a class, which I am calling from PointerClick(in EventTrigger).
Need to recall PointerClick after the first PointerClick((0.2f) seconds later).

• It's not immediately clear what you're looking for here - can you explain in more detail? – DMGregory Feb 27 '18 at 20:26

1. Make sure you have a PhysicsRaycaster or Phyics2DRaycaster on your camera if the object holding this script is a 3D / 2D object. If it's a UI object, you have to put a GraphicRaycaster
2. Make sure the object holding this script has a Collider or Collider2D or an Image/RawImage component with RaycastTarget checked
3. Make sure you have an EventSystem in your scene

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class ClassName: MonoBehaviour, IPointerClickHandler
{
public float doubleClickThreshold = 0.2f ;
public UnityEvent OnDoubleClickDetected;
private float lastClickTime = -1 ;

public void OnPointerClick(PointerEventData ped)
{
if( Time.time - lastClickTime < doubleClickThreshold )
{
if( OnDoubleClickDetected != null )
OnDoubleClickDetected.Invoke() ;
}
lastClickTime = Time.time ;
}
}

• I want to imitate second click after the first one. – GuardFromUA Feb 28 '18 at 12:06
• You want to simulate the double click? I'm afraid this is not possible with Unity only. You have solutions for Windows only if you want. Why do you want the double click? Have you currently something like a listener to a double click event? – Hellium Feb 28 '18 at 12:10
• Yes. I have listener. Having problems with cards swipe. What to make all image be raycasted, but then I can't swipe.. – GuardFromUA Feb 28 '18 at 12:12
• Please, edit your question and provide all the relevant code if you want an answer fitting your needs. – Hellium Feb 28 '18 at 12:14

Not sure if I understood but you can try: Invoke( method(), time ); to call some method after certain time