Search Unity

[Solved] Tapping a UI button

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Feb 17, 2015.

  1. Deleted User

    Deleted User

    Guest

    I noticed that when you press a UI button, it doesn't matter how long you press it, it will always register and activate.
    What if you want to make it only activate on "Tap"? And a tap would be up to 1 second. Is this possible to do with the new UI system?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Yes it's possible. You would just need to create a script with the IPointerDownhandler and IPointerUpHandler interfaces.

    Then keep a timer between the events occurring and only action when it is within a certain time limit.
     
  3. Deleted User

    Deleted User

    Guest

    What would I do once I have created the script? How would I use it with the Button component?
     
  4. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Deleted User likes this.
  5. Deleted User

    Deleted User

    Guest

    Thanks that's really useful. I already made it inherit from Button but public variables don't show in the Inspector. I'll try to just copy & paste the code you posted and see how it works with that.
    Thanks.