How To Inactivate Childs of a GameObject (GUI)

Hi,
I’m new to Unity and i try to create a menu by using the new GUI (4.6).
I want a menu looking like the KeyNote menu, with a panel to the right of the scene which changes when we click one of the buttons.

All my panels are in a EmptyGameObject.
If i inactivate this GameObject i can’t activate a specific panel after.
My idea was :

  1. Inactivate all the panels to make sure any pre-existent panels are deactivated
  2. Activate the panel linked to the button (with SetActive)

I do not managed to inactivate all the children of the GameObject, any solutions ?
If u have a better idea on how to make this kind of menu, feel free to contribute.


Thanks.
Please excuse my poor English

You can get the children of your EmptyGameObject and deactivate them one by one.
After that you can activate the one you like to have active.

		for (int i = 0; i < transform.childCount; i ++)
		{
			transform.GetChild(i).gameObject.SetActive(false);
		}

Thanks !
I did something similar and it’s working fine.

public void ActivatePanel(string panelId)
    	{
    		foreach(Transform child in transform)
    		{
    			if(child.name == panelId)
    			{
    				child.gameObject.SetActive(true);
    			}
    			
    			else{
    				child.gameObject.SetActive(false);
    			}
    		}
    		
    	}