Setting my child objects to active

Hi,

I have read many of the questions about the new SetActive(bool) function but I still cant get my script to work. I have an always active parent object that way I should be able to access my children even if they are inactive and activate them, but its not working.

Can someone take a look?

Here is my hierarchy:

13411-capture.jpg

And here is my script on the Panel Manager:

public class PanelManager : MonoBehaviour {

	public GameObject mainMenuPanel;
	public GameObject myProfilePanel;
	
	
	// Use this for initialization
	void Start () 
	{
		mainMenuPanel.SetActive(true);
		myProfilePanel.SetActive(false);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	public void UpdateCurrentPanel(string panelName)
	{
		foreach(Transform child in transform)
		{
			if(child.name == panelName)
			{
				child.gameObject.SetActive(true);
			}
			
			else
				child.gameObject.SetActive(false);
		}
		
	}
}

I have made sure all spellings are correct, etc. The UpdateCurrentPanel method is called from button clicks on each panel and passes the name of the panel to activate.

if im reading this correctly you are trying to toggle the active of childs of a gameobject. And when you push a button the following gets called

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

What this looks like to me is it will turn them off but not turn them on because there is only logic for turning them off if the name is not equal to panelName but you need logic to turn them back on so try the following

    public void UpdateCurrentPanel(string panelName)
            {
               foreach(Transform child in transform)
               {
                 if(child.name == panelName)
                 {
                  child.gameObject.SetActive(true);
                 }
         
                 else{
                      //show being a bool you store
                      show = !show
                      child.gameObject.SetActive(show );
                   }
               }
         
            }