public static Transform GetChild(Transform parentTF,string childName)
{
Transform childTF=parentTF.Find(childName);
if(childTF!=null)
{return childTF;}
int count =parentTF.childCount;
for(int i=0;i<count;i++)
{
childTF=GetChild(parentTF.GetChild(i).childName);
if(childTF!=0)
{return childTF;}
}
return null;
}
C#脚本中在层级未知情况下查找子物体,主要用find和getchild连个函数
最新推荐文章于 2024-03-18 11:11:07 发布