- Home /
This question was
closed Aug 05, 2013 at 10:40 PM by
ryisnelly for the following reason:
The question is answered, right answer was accepted
add close button to script
how would i add a close button to this script to make the gui close thanks
var information: String;
private var guiOn = false;
private var rect: Rect;
var btnTexture : Texture;
function OnMouseDown(){
guiOn = true;
rect = Rect(Input.mousePosition.x, Input.mousePosition.y, 300, 100);
yield WaitForSeconds(500);
guiOn = false;
}
function OnGUI(){
if (guiOn){
GUI.Box(Rect(0,0,200,200),"Current bid");
if (!btnTexture) {
Debug.LogError("Assign a texture");
return;
}
if (GUI.Button(Rect(10,10,50,50),btnTexture))
Debug.Log("Image Button");
if (GUI.Button(Rect(10,70,50,30),"Bid"))
Debug.Log("Text button");
}
}
Comment
Best Answer
Answer by clunk47 · Aug 05, 2013 at 10:30 PM
Simple. In your GUI code, add a button like you did the other buttons.
if(GUI.Button(Rect(64, 10, 50, 50), "Close"))
guiOn = false;