- Home /
Question by
corpius4 · Dec 31, 2011 at 07:41 PM ·
if statementgui.label
No mater what I cannot make this GUI button true! please help.
function OnGUI () {
if (GUI.Button(Rect(10,10,40,40),"hi"))
{
GUI.Label(Rect(250,250,400,400),"you did it!");
print("hi");
}
else{print("ho");}}
Comment
Answer by karl_ · Dec 31, 2011 at 07:48 PM
It is being made true, but only for the frame that you clicked it. If you want the "You did it" to stay on screen, you will need to make the button toggle it on or off. Example below:
var showLabel : boolean = false;
function OnGUI () { if (GUI.Button(Rect(10,10,40,40),"hi")) { showLabel = true; }
if(showLabel)
GUI.Label(Rect(250,250,400,400),"you did it!");
}
Your answer
Follow this Question
Related Questions
GUI.Button("german umlauts like ") missing 2 Answers
Problem with centering text 1 Answer
How to change word space ? 2 Answers
Instantiate particles with double if statement 1 Answer
help with boss death (bool) 1 Answer