小编edw*_* au的帖子

让最底层的孩子

我知道获得最高的父母是。transform.root如果我想获得最低的孩子并且在我不知道孩子名字的情况下该怎么办?

for (int i=0; i<theParent.childCount; i++) 
{
 int bottommost=theParent.childCount-1;
 Debug.Log(theParent.GetChild(bottommost).name);
}
Run Code Online (Sandbox Code Playgroud)

但是不是我期望的结果,我只是得到第一个孩子,但是我想要最底层的孩子。顺便说一句,我的意思是层次结构中最底层的孩子。

unity-game-engine

1
推荐指数
1
解决办法
4495
查看次数

标签 统计

unity-game-engine ×1