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

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

int childCount = transform.childCount;
for (int i=0; i<childCount; i++) {
    Transform child=transform.GetChild (i);
}

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

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

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的更多相关文章

  1. struts标签<logic:iterate>的用法

    <logic:iterate>主要用来处理在页面上输出集合类,集合一般来说是下列之一: 1. java对象的数组 2. ArrayList.Vector.HashMap等 具体用法请参考s ...

  2. node与Elment以及子节点childrenNode与children的区别(2)

    测试代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  3. Javascript DOM基础(二) childNodes、children

    childNodes知识点: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Typ ...

  4. hduoj 4706 Children&#39;s Day 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4706 Children's Day Time Limit: 2000/1000 MS (Java/Others) ...

  5. HDU 4706:Children's Day

    Children's Day Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  6. HDU4706:Children's Day

    Problem Description Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' i ...

  7. struts1吊牌&lt;logic:iterate&gt;

    <logic:iterate>主要用于处理网页上的输出集合,集合是其中一般下列之一: 1. java对象的数组 2. ArrayList.Vector.HashMap等 具体使用方法请參考 ...

  8. 由获取子元素的方法find和children所获

    html代码如下 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://ww ...

  9. 【JAVASCRIPT】React学习-巧用 props 的 children 属性实现内容填充

    背景 平常写组件,经常遇到需要获取内容放入组件内部的情形. 实现方法 我们有两种实现方式 1. 自定义 props render 的时候通过获取 this.props.content 填充到组件内部 ...

随机推荐

  1. Android Broadcast Security(转)

    原文地址:http://drops.wooyun.org/tips/4393 0x00 科普 Broadcast Recevier 广播接收器是一个专注于接收广播通知信息,并做出对应处理的组件.很多广 ...

  2. HDU 4665 Unshuffle (2013多校6 1011 )

    Unshuffle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  3. VITAM POST MORTEM – ANALYZING DEADLOCKED SCHEDULERS MINI DUMP FROM SQL SERVER

    https://gennadny.wordpress.com/2014/11/ Since SQL Server 7.0, SQL Server has its own scheduling mech ...

  4. Android 垃圾回收,用软引用建立缓存

    内存对于手机来说是非常重要的. 下面总结了我们在注意创建对象时的规则,以及怎么更好更快的实行GC回收,和怎么构建高速的对象cace缓冲. 1 避免循环遍历的创建对象,哪怕对象很小,也是要占资源的. 2 ...

  5. Xcode no visible @interface for XXX declares

    出现如上面的错误, 是因为没有找到这个方法, 要自己写一个这样的方法 , 如果这是个类目的方法的话,  需要在Target->Linking->Other Linker Flags中添加- ...

  6. 图灵机器人聊天api

    图灵机器人,功能非常强大,可用于聊天.查询等多个领域 图灵机器人官网:http://www.tuling123.com api地址:http://www.tuling123.com/openapi/a ...

  7. Mac 清除/修改SSH的私钥密码

    我之前在Mac下用命令ssh-keygen生成密钥,并且安全起见为密钥设置了密码,这样导致后来每次我git push时,都要输入一次密码: Enter pass phrase for /Users/z ...

  8. 图片转为byte[]、String、图片之间的转换

    package com.horizon.action; import java.io.ByteArrayOutputStream; import java.io.File; import java.i ...

  9. 如何使用angularjs实现文本框设置值

    <!DOCTYPE html> <html ng-app="myApp"> <head> <title>angularjs-setV ...

  10. Word2007中插入公式之后,公式上下有很大的空白

    word 2007 选中一个公式,选择页面布局,点击页面设置右下角的小箭头,在弹出的对话框中,选择文档网格,在网格选项中选择无网格,确定,行距正常了. 选择一个公式,所有的公式行距都会变. Word ...