there are 9 child gameobjects to a parent.
only one child is active at a time, rest are disabled.
I want to do something like
if current active childindex is less than 4 then setactive(false) all the children and setactive(true) childindex(0)
if current active childindex is between 4 - 9 then setactive(false) all the children and setactive(true) childindex(4)
currently I have if statement for all 9 childrens like so
if (transform.GetChild(1).gameObject.activeInHierarchy == true)
{
transform.GetChild(1).gameObject.SetActive(false);
transform.GetChild(0).gameObject.SetActive(true);
}
if (transform.GetChild(2).gameObject.activeInHierarchy == true)
{
transform.GetChild(2).gameObject.SetActive(false);
transform.GetChild(0).gameObject.SetActive(true);
}
and so on. but I know there must be a better way to deal with this. so please help. thanks in advance.