public static GameObject FindHideChildGameObject(GameObject parent, string childName)
{
if(parent.name == childName)
{
return parent;
}
if(parent.transform.childCount < 1)
{
return null;
}
GameObject obj = null;
for(int i = 0;i<parent.transform.childCount;i++)
{
GameObject go = parent.transform.GetChild(i).gameObject;
obj = FindHideChildGameObject(go, childName);
if(obj != null)
{
break;
}
}
return obj;
}
Unity根据名称递归查找一个物体的子物体
最新推荐文章于 2022-06-08 15:26:17 发布