public static GameObject GetGo(GameObject parent, string childName)
{
//找第一代
int count = parent.transform.childCount;
if (count == 0)
{
return null;
}
GameObject childTf = parent.transform.Find(childName).gameObject;
if (childTf != null)
return childTf;
{
//找第一代
int count = parent.transform.childCount;
if (count == 0)
{
return null;
}
GameObject childTf = parent.transform.Find(childName).gameObject;
if (childTf != null)
return childTf;
//获得子代的数量
for (int i = 0; i < count; i++)
{
childTf = GetGo(parent.transform.GetChild(i).gameObject, childName);
if (childTf != null)
break;
}
return childTf;
}
for (int i = 0; i < count; i++)
{
childTf = GetGo(parent.transform.GetChild(i).gameObject, childName);
if (childTf != null)
break;
}
return childTf;
}