Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How to trigger a button as soon as it's tapped/pressed instead of on release?

Discussion in 'UGUI & TextMesh Pro' started by roseportalgames, Jan 14, 2019.

  1. roseportalgames

    roseportalgames

    Joined:
    Aug 9, 2017
    Posts:
    173
    OnClick only triggers if a button is pressed and released with the cursor (or finger) still over the button. To avoid this buggy looking situation, I'd like to trigger the button as soon as it's pressed/tapped. How can I achieve this?

    OnMouseDown does not work.

    Thanks. :)
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,061
    Add an
    Event Trigger
    to your button object and add the event type
    Pointer Down
    there.
    You may exchange the
    Button
    Component with a
    Selectable
    Component since you do not need the callback of the button anymore.
     
  3. MarkoGisG

    MarkoGisG

    Joined:
    Jan 22, 2023
    Posts:
    1
    Thanks bro that helped a lot!