Stick them in an array, iterate on the array. So on your button that opens a panel, send an index value that corresponds to the panel to be opened. Then you can just turn on that panel from the array. Something like this:
[SerializeField] GameObject[] panelList;
[SerializeField] GameObject[] panelList;
void ResetPanels()
{
for(int i = 0; i < panelList.Length; i++)
{
if(panelList[i].activeSelf) panelList[i].SetActive(false);
}
}
public void OpenPanel(int index)
{
ResetPanels();
panelList[index].SetActive(true);
}
Comments
Post a Comment
Please feel free to comment. I would love to hear feedback.