Search Unity

Preventing OnClick() event if OnLongPress() event occured

Discussion in 'UGUI & TextMesh Pro' started by gfxguru, Jun 28, 2015.

  1. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    I have a Unity UI button , with an OnClick() event , and i have added a custom event for LongPress. But the problem is after the longpress is triggered, when i take finger, the on click event is also called. So , how can we prevent onclick event if longpress occured.

    Thanks in advance
     

    Attached Files:

  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It seems to be the easiest way to have LongPress and maybe Tap, where tap is just a click that is shorter than a long press. Like that you don't need OnClick anymore and you have a solid solution.
     
  3. gfxguru

    gfxguru

    Joined:
    Jun 5, 2010
    Posts:
    107
    thanks dantus
    i have a lot of button already mapped with onclick() , the tap is added by another script. So i was looking for a solution to keep onclick like that and get longpress