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;
}
}

最新文章

  1. Jsoup提取文本时保留标签
  2. 转载:移动前端开发之viewport的深入理解
  3. Apache查看并发及TIME_WAIT过多的解决
  4. sqlplus命令大全
  5. drupal里面的ajax最粗浅的理解-流程
  6. NodeJS记录
  7. android ListView进阶
  8. [r]How To Use Git To Create A Key
  9. 新版福昕阅读器(Foxit Reader)启动速度慢解决办法
  10. response的contentType 几种类型
  11. NSConditionLock
  12. 将UTF8编码转化为中文 - NSString方法
  13. Python hashlib 无法打印
  14. 134、直接拿来用,Android界最火的开源项目
  15. 图片缓存:浏览器刷新 和 304 Not Modified 与 If-Modified-Since 及 Cache-Control
  16. poj 1184
  17. [C#]读取不同版本的excel文件的方法
  18. Java数据结构和算法(一)散列表
  19. AdvStringGrid 复选框、goRowSelect
  20. 用Keras 和 DDPG play TORCS(1)

热门文章

  1. Entity Framework Code First - Change Tracking
  2. Ubuntu16.04安装Mininet
  3. 《FPGA全程进阶---实战演练》第二十一章 细说低速与高速电路设计之电阻 电容 电感 磁珠
  4. 技能UP:SAP CO掌上配置手册
  5. 第三百二十三节,web爬虫,scrapy模块以及相关依赖模块安装
  6. 对 /etc/rc.d/init.d 目录的一点理解
  7. JDBC SQL语法
  8. CI框架 -- 创建类库
  9. android项目引入三方类库配置文件
  10. Ubuntu一般软件安装后的路径