class AddComponentRecursively extends ScriptableWizard {

    var componentName : String = "";

    @MenuItem ("GameObject/Add Component Recursively...")

    static function AddComponentsRecursivelyItem() {
ScriptableWizard.DisplayWizard("Add Component Recursively", AddComponentRecursively, "Add", "");
} //Main function
function OnWizardCreate() {
var total : int = ;
for (var currentTransform : Transform in Selection.transforms) {
total += RecurseAndAdd(currentTransform, componentName);
}
if (total == )
Debug.Log("No components added.");
else
Debug.Log(total + " components of type \"" + componentName + "\" created.");
} function RecurseAndAdd(parent : Transform, componentToAdd : String) : int {
//keep count
var total : int = ;
//add components to children
for (var child : Transform in parent) {
total += RecurseAndAdd(child, componentToAdd);
}
//add component to parent
var existingComponent : Component = parent.GetComponent(componentToAdd);
if (!existingComponent) {
parent.gameObject.AddComponent(componentToAdd);
total++;
} return total;
}
//Set the help string
function OnWizardUpdate () {
helpString = "Specify the exact name of the component you wish to add:";
} // The menu item will be disabled if no transform is selected.
@MenuItem ("GameObject/Add Component Recursively...", true) static function ValidateMenuItem() : boolean {
return Selection.activeTransform;
}
}

AddComponentRecursively的更多相关文章

随机推荐

  1. ps 和 grep 查找消除 grep自身查找

    用ps -def | grep查找进程很方便,最后一行总是会grep自己. $ ps -def | grep dragonfly-framework dean 5273 5272 0 15:23 pt ...

  2. wifi 通过omnipeek 查看 pmf是否生效

    给android的wifi设备添加PMF支持时,抓取omnipeek分析. 从assoc req 中发现相关标志位没有使能,说明STA 没有使能PMF RSN Capabilities: %00000 ...

  3. 使用3ds Max制作简单卧室

    一.介绍 学习目标:熟练使用“标准基本体”和“扩展基本体”内的按钮来创建对象. 软件环境:3ds Max2015 二.实验步骤 1,启动3ds Max,使用“长方体”工具在场景中创建一个长方体作为空间 ...

  4. 第三百五十六节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy分布式爬虫要点

    第三百五十六节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy分布式爬虫要点 1.分布式爬虫原理 2.分布式爬虫优点 3.分布式爬虫需要解决的问题

  5. java做web项目比较多

    WEB就是轻量级:如果要炫,FLEX或即将普及的html5.0都能做到像C/S那样. java做web项目比较多:如果是桌面程序,还是走C/S比较成熟. 如果是B/S架构的,后台还是JAVA,前台可以 ...

  6. javascript -- canvas绘制曲线

    绘制曲线有几种思路: 1.通过quadraticCurveTo(controlX, controlY, endX, endY)方法来绘制二次曲线 2.通过bezierCurveTo(controlX1 ...

  7. 一步步配置cordova android开发环境

    .先安装jdk-8u111-windows-x64(安装jdk1.) .安装android sdk(Android Stand-alone SDK Tools) .配置环境变量 环境变量: JAVA_ ...

  8. Java 注解 (Annotation)

    Java 注解用于为 Java 代码提供元数据.作为元数据,注解不直接影响你的代码执行,但也有一些类型的注解实际上可以用于这一目的.Java 注解是从 Java5 开始添加到 Java 的. 注解语法 ...

  9. lvm讲解/磁盘故障小案例

    4.10/4.11/4.12 lvm讲解 4.13 磁盘故障小案例 lvm讲解 磁盘故障小案例

  10. UNIX环境编程学习笔记(27)——多线程编程(二):控制线程属性

    lienhua342014-11-09 1 线程属性概括 POSIX 线程的主要属性包括 scope 属性.detach 属性.堆栈地址.堆栈大小.优先级.在头文件 pthread.h 中定义了结构体 ...