I want to create a button that when you press it, a new button will open. I know how to make both buttons, but I can’t manage to hide the first button once clicked.
This is my code so far:
#pragma strict
function Start ()
{
}
function Update ()
{
}
var isButtonVisible : boolean = true;
var buttonRectangle : Rect = Rect(100, 100, 100, 50);
function OnGUI ()
{
var NewButton = GUI.Button(Rect (Screen.width / 2 - 75, Screen.height / 2 -25,150,50), "this is also a button");
if ( isButtonVisible )
{
if ( GUI.Button(Rect (Screen.width / 2 - 75, Screen.height / 2 -25,150,50), "button") )
{
isButtonVisible = false;
if ( isButtonVisible )
{
return NewButton;
}
}
}
}
I am new to programing so this question might be a bit unclear.
I agree with “Happy Apple’s” solution, and just to expand on this if you wanted to integrate reverse functionality you can simply alter the code as follows:
Hope this is helpful.