SHARE
TWEET

Double Click UI

hottabych Jun 1st, 2020 522 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class DoubleClick : MonoBehaviour, IPointerDownHandler
  2. {
  3.     float clicked = 0;
  4.     float clicktime = 0;
  5.     float clickdelay = 0.5f;
  6.  
  7.     public void OnPointerDown(PointerEventData data)
  8.     {
  9.         clicked++;
  10.         if (clicked == 1) clicktime = Time.time;
  11.  
  12.         if (clicked > 1 && Time.time - clicktime < clickdelay)
  13.         {
  14.             clicked = 0;
  15.             clicktime = 0;
  16.             Debug.Log("Double CLick: " + GetComponent<RectTransform>().name);
  17.  
  18.         }
  19.         else if (clicked > 2 || Time.time - clicktime > 1) clicked = 0;
  20.     }
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top