Problem in disabling button and error in the statement
Hello guys
I’m trying to build a simple mathematics game, I'm using Unity 5.4.1f1 (64-bit), I have in my game 10 buttons each one have a number 0 to 9 and a simple button “Enter” I create a simple code for the button’s if you click a number this number will showing in a textview and then the button disabled but never your number start with 0 so this condition make me angry I try much time but no way work
Below you can see my code if (a == 0 && multiplayer < 3) { ChangeSpriteOfBtn (myBtn0); } else if (a == 1) { ChangeSpriteOfBtn (myBtn1); } else if (a == 2) { ChangeSpriteOfBtn (myBtn2); } else if (a == 3) { ChangeSpriteOfBtn (myBtn3); } else if (a == 4) { ChangeSpriteOfBtn (myBtn4); } else if (a == 5) { ChangeSpriteOfBtn (myBtn5); } else if (a == 6) { ChangeSpriteOfBtn (myBtn6); } else if (a == 7) { ChangeSpriteOfBtn (myBtn7); } else if (a == 8) { ChangeSpriteOfBtn (myBtn8); } else if (a == 9){ ChangeSpriteOfBtn (myBtn9); } } }
public void block0number(int b){
if (multiplayer >= 3 && b == 0) {
PrintValue2.text = "number can't start with 0";
multiplayer++;
}
}
public void addNumber(int d){
k++;
block0number (d);
if (multiplayer >= 0) {
result *= 10;
result += d;
storeValue = result;
multiplayer -= 1;
if (multiplayer ==-1) {
storeValue = result;
PrintValue2.text = "" + storeValue;
}
}
else {
PrintValue2.text="max 4 digit in the number you put "+k+" number"
}
}
}
When I add the condition in this line if(a == 0 && multiplayer < 3)
the program give me a wrong result first the button never disabled and also you can click the button more than one time but in my game you can’t click the same button more than one time also my number have 4 digit and this number never start with 0 finally the multiplayer variable start with 3 and I’m using the multiplayer in the condition of the 0 button in below some screenshot for more understand my problem i hope find some help, finally thanks for all reply :)
Your answer
Follow this Question
Related Questions
Second button works 4 times 1 Answer
Disable or hide GUI Buttons on one scene 2 Answers
error CS1041: Identifier expected 1 Answer
Start animation with different game object 0 Answers
Is it possible to Run R Code from Unity C# in Mono or .NET? 0 Answers