gpt4 book ai didi

c# - 得到最底层的 child

转载 作者:行者123 更新时间:2023-12-04 00:08:17 27 4
gpt4 key购买 nike

据我所知,要获得最顶层的父级是 transform.root 。如果我想获得最底层的子级并且在我不知道子级名称的情况下怎么办?我试过了

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

但这不是我期望的结果,我只得到第一个 child ,但我想要最底层的 child 。顺便说一句,我的意思是层次结构中最底层的 child 。这有什么技巧可以得到最底层的 child 吗?谢谢.

最佳答案

lastChild = transform.GetChild(transform.childCount - 1);

关于c# - 得到最底层的 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26622675/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com