static void Activate (Transform t)
{
SetActiveSelf(t.gameObject, true);
// Prior to Unity 4, active state was not nested. It was possible to have an enabled child of a disabled object.
// Unity 4 onwards made it so that the state is nested, and a disabled parent results in a disabled child.
#if UNITY_3_5
for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
{
Transform child = t.GetChild(i);
Activate(child);
}
#else
// If there is even a single enabled child, then we're using a Unity 4.0-based nested active state scheme.
/*for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
{
Transform child = t.GetChild(i);
if (child.gameObject.activeSelf) return;
}*/
// If this point is reached, then all the children are disabled, so we must be using a Unity 3.5-based active state scheme.
for (int i = 0, imax = t.GetChildCount(); i < imax; ++i)
{
Transform child = t.GetChild(i);
Activate(child);
}
#endif
}