- Home /
Question by
paco morales · Jan 12, 2013 at 10:52 PM ·
guibuttonfunctionskin
How to set GUI button "1" to "0"?
Hi I'm trying to set a GUI button to triggerGo = 0; Because I'm using a Static Variable to enable a script in other object.
So a need to use the same button, But when I hit the button its only makes "triggerGo == 1" so I can't disable the script in my other object.
Here you can see my script
Any advice?
Thanks in advance!
function OnGUI (){
GUI.skin = Skin_power;
if (GUI.Button(Rect(870,227,80,56),"")){
audio.PlayOneShot(beep);
triggerGo = 1;
print(triggerGo);
}
Comment
You could consider a use of an on/off GUI.Toggle button
Best Answer
Answer by robertbu · Jan 13, 2013 at 02:31 AM
You could do something like:
triggerGo = (triggerGo + 1) % 2;
This will flop triggerGo between 0 and 1.
If it just two values, you could use a boolean:
triggerGo = !triggerGo;
Your answer
Follow this Question
Related Questions
Create GUI based on an array 2 Answers
Embed GUI Skin in GUI Button 2 Answers
Automatic new line 1 Answer