Hi, I have the following code:
function OnGUI(){
if(GUI.Button(Rect(10,10,50,30), "Button1")){
var object1=GameObject.Find("An object");
object1.SetActiveRecursively(true);
}
}
But every time I click the button it should show/hide/show/hide. How can I do this? What I tried:
function OnGUI(){
if(GUI.Button(Rect(10,10,50,30), "Button1")){
var object1=GameObject.Find("An object");
if(!object1){
object1.SetActiveRecursively(true);
}else{
object1.SetActiveRecursively(false);
}
}
}
Thanks for the help!