**I’m trying to create a script for turning gameObjects on and off. I want it when I touch on the first button another 2 buttons will appear to select what design of the object they want to put. for example on first button it is named as BED, then when you click BED there will be two buttons that will appear named blue bed and red bed, for example blue bed is clicked the blue bed will be activated. and when red bed, the red bed will be shown.
here in my code when i Click on first button another button will appear but the function in the second button is already executed when the first button is click:**
bool toggle = false;
public GameObject targetItem;
void Start(){
targetItem.SetActive (false);
}
void OnGUI (){
if (Input.GetKeyDown(KeyCode.Escape)){
//Camera.mainCamera.backgroundColor = Color.red;
Application.LoadLevel(6);
}
if (GUI.Button (new Rect (150, 420, 100, 50), "Sofa")) {
toggle=!toggle;
}
if (toggle)
{
if (GUI.Button (new Rect (150, 350, 100, 50), "Sofa"))
;
{
targetItem.SetActive(true);
}
}
}
}