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. 【CUDA学习】__syncthreads的理解

    __syncthreads()是cuda的内建函数,用于块内线程通信. __syncthreads() is you garden variety thread barrier. Any thread ...

  2. ecmall数据库表详解 二次开发必备

    文章分类表ecm_acategory 字段 类型 Null 默认 注释 cate_id int(10) 否   自增ID号,分类ID号 cate_name varchar(100) 否   分类的名称 ...

  3. 【Html】Vue动态插入组件

    html: <div id="app"> <p>{{ message }}</p> <button @click="add('a ...

  4. SSH-运行main函数,一直报空指针,调依赖注入配置的dao

    解决this.getHibernateTemplate()==null的问题 刚刚在整合SSH时碰到了这样一个问题: 当我用junit测试时不会报任何异常,数据也都能得到 但当我运行man函数,直接n ...

  5. VIM下的插入模式的相关知识:

    1. 建议:当打错一个单词时,删除掉重新打一遍, 避免在错誤的基础上进行修改: 2. 在插入模式下,可以用一些组合键,它也可以用于VIM 命令模式下,也可以用于 base shell 下: ctrl- ...

  6. JAVA编程环境JDK与JRE运行环境与API核心ClassMap

    JDK(Java Development Kit)称为Java开发包或Java开发工具,是一个编写Java的Applet小程序和应用程序的程序开发环境.JDK是整个Java的核心1.Java运行环境( ...

  7. Newtonsoft.Json 序列化小写首字母

    //json对象命名小驼峰式转换var json = JsonConvert.SerializeObject(newAccount, Formatting.Indented, new JsonSeri ...

  8. win10 UWP Markdown 含源码

    Windows下没有比較好的Markdown编辑器 我就自己写一个 csdn的Markdown非常好,就是我须要截图保存有麻烦 须要把我的截图保存在本地,然后上传 这个过程比較麻烦 csdn的图没法外 ...

  9. C# 之HTTP请求get,post带重试参数

    public class WebHttp { /// <summary> /// get请求带重试 /// </summary> /// <param name=&quo ...

  10. linux升级php至5.6

    1 查看终端当前php版本 php -v 会反馈以下信息: PHP 5.4.35 (cli) (built: Nov 14 2014 07:04:10) Copyright (c) 1997-2014 ...