- Home /
how to disable a button after pressing it and enable again after pressing another button
i have a code for a QandA game where in when you pressed attack a gui box with question will appear and if you choose an answer, animation will play, my problem is when the animation play i can still click the attack button and gui will pop up, what i want is when i press the attack button and choose an answer then the animation plays i wont be able to press it again until my animation ends
here's my code
void DrawInfo() {
Rect rect = new Rect(500, 100, 400, 200);
Rect close = new Rect(600, 500, 200, 100);
if(GUI.Button(close, "ATTACK"))
Answer by Nanobrain · Feb 04, 2014 at 04:58 AM
Try:
if(!animation.isPlaying()) {
if(GUI.Button(close, "ATTACK"))
}
That way your attack button is only displayed if the animation is NOT playing.
hmm im sorry im kinda noob for this but when i put it i get errors can you explain it further if its okay and where should I put it thank you
if(!animation.isPlaying()) {
if(GUI.Button(close, "ATTAC$$anonymous$$")) {
Poop = !Poop;
}
}
That's where you should put it. Just like that, which is within your DrawInfo() method.
okay i got it thank you by the way what if you have two kinds of animation is it right to code it this way
if(!animation.isPlaying("CORRECT")) {
if(!animation.isPlaying("Incorrect")) {
if(GUI.Button(close, "ATTAC$$anonymous$$")) {
Poop = !Poop;
}
}
}