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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Only Allow one Button to be Pressed at a Time

Discussion in 'UGUI & TextMesh Pro' started by vabster, Jan 7, 2016.

  1. vabster

    vabster

    Joined:
    May 12, 2013
    Posts:
    14
    Hello!

    I'm making a mobile game with multiple buttons. Right now if a user clicks on two buttons at the same time and releases, both OnClick functions activate, and I want only one to activate (or even neither to activate). For example, on my home screen I have a Play button and a Shop button, and if the user presses both at the same time it will open the shop menu and start the game. Is there any easy solution to this?

    Thanks in advance!
     
  2. Optimus_Prime

    Optimus_Prime

    Joined:
    Apr 15, 2015
    Posts:
    34
  3. vabster

    vabster

    Joined:
    May 12, 2013
    Posts:
    14
    Thanks for the reply. I think I figured it out by disabling the other buttons using OnPointerDown and then re-enabling them using OnPointerExit.