首页 > 编程语言 > 详细

unity, iterate immediate children and iterate all children

时间:2015-07-01 06:12:01      阅读:269      评论:0      收藏:0      [点我收藏+]

遍历所有直接子节点(immediate children):

foreach (Transform child in transform)
{
    // do whatever you want with child transform object here
}

注:transform.childCount返回的是直接子节点个数。

遍历所有子节点(包括根节点本身及所有子孙节点):

Transform[] allChildren = GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren) {
    // do whatever with child transform here
}

参考:http://answers.unity3d.com/questions/10417/how-can-i-access-the-children-of-a-transform.html

unity, iterate immediate children and iterate all children

原文:http://www.cnblogs.com/wantnon/p/4612222.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!