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. Linux 文件编码格式转换

    如果需要在Linux 中操作windows下的文件,那么经常遇到文件编码转换的问题. Windows中默认的文件格式是GBK(gb2312),而Linux一般都是UTF-. 查看文件编码 在vim 中 ...

  2. Qt 菜鸟的坑 QAbstractSocket::isValid()

    我曾经多次在 Qt socket 编程中使用 tcpSocket.isValid 来判断我当前的连接是否可用,最近写程序时才发现此法并不妥当. bool QAbstractSocket::isVali ...

  3. SEMI-PARAMETRIC TOPOLOGICAL MEMORY FOR NAVIGATION

    github: https://github.com/nsavinov/SPTM

  4. python with 语句妙用

    class aa(): def bb(self): print("hhhh") return "hello world" def __enter__(self) ...

  5. Cisco无线控制器配置Radius

    使用Cisco无线控制器管理AP,配置Radius服务器,用于企业加密wifi的认证. 结合上一篇文档进行操作: http://www.cnblogs.com/helloworldtoyou/p/80 ...

  6. MySQL 服务(mysqld)crash

    场景:     数据从 10.165.98.190 自建MySQL同步至 阿里云 MongoDB过程中,mysql服务会崩溃,同步数据失败. 原因分析:     经DBA 分析,10.165.98.1 ...

  7. Git -- 远程仓库简介

    到目前为止,我们已经掌握了如何在Git仓库里对一个文件进行时光穿梭,你再也不用担心文件备份或者丢失的问题了. 可是有用过集中式版本控制系统SVN的童鞋会站出来说,这些功能在SVN里早就有了,没看出Gi ...

  8. Shiro Demo

    http://www.sojson.com/shiro http://blog.csdn.net/swingpyzf/article/details/46342023/

  9. js Jquery字符UrlEncode 编码 C#(asp.net)解码 Server HttpUtility 区别 cookies存中文

    一.Js asp.net 交互Url编码解码 C#(asp.net)编码:HttpUtility.UrlEncode(url) Jquery解码:decodeURIComponent(url); Jq ...

  10. 原版的WEB认证客户端,提供源代码,让用户自行编译

    今天在翻找文件,偶尔发现这个文件,就把源代码发给大家吧. 有需要的,可以尽管改,程序在D7下编译 下载地址:下载地址1