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:
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.