Double Button Presses - Mobile

Hi everyone,

I’m stumped with the problem. Hopefully someone can steer me in the right direction.

See attached image of the two buttons I have in my UI scene. On mobile the user is able to press both of the buttons at the same time resulting in unwanted behaviour. I need to find out how to prevent the user from pressing both buttons at the same time and the code running for both.

The code is based on which ever button the user presses. If you press A you get ID 0 and the if statement in the below code is run. If you press B ID 1 is used and other if statement is run.

At the moment the user is able to press both A and B in a scene and do both options at once (using a double press). How can I limit it so that only one button can be pressed at once.

Im using the UI buttons for this. I have tried using the OnClick event that is default on buttons as well as the alternative PointerDown event. Both produce the same results.

Thanks.

public void UserInput(intid)
 {
int type = typeList[questionNum -1];

if(type == 1)
 {
switch (id)
 {
case0:
Debug.Log("A");
userScore += 1;
break;
case1:
Debug.Log("B");
userScore += 2;
break;
 }
 }

if(type == 2)
 {
switch (id)
 {
case0:
Debug.Log("A");
userScore += 2;
break;
case1:
Debug.Log("B");
userScore += 1;
break;
 }
 }

moveToNextQuestion();
 }


public void UserInput(intid)
{
int type = typeList[questionNum -1];
if(type == 1)
{
   if(id == 0) {
        Debug.Log("A");
        userScore += 1;
    } else if (id == 1) {
        Debug.Log("B");
        userScore += 2;
    }
} else if (type == 2) {
    if(id == 0) {
        Debug.Log("A");
        userScore += 2;
    } else if (id == 1) {
        Debug.Log("B");
        userScore += 1;
    }
}

quick and dirty

or you make 2 bools isPressed_A and isPressed_B pressing one of the buttons sets the corresponding bool to true and now you can check if isPressed_B or _A for true/false to block other button input.