AddComponentRecursively
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的更多相关文章
随机推荐
- Qt中如何根据类名来实例化对象
对于Qt 来说,是可以做到运行时,根据对象的类名字(字符串)来获得对象的实例的,这点和一些语言的反射机制是一样的. 但是在Qt中,我们需要所额外的一步,就是注册.只要做到了注册,我们就可以 自由的创建 ...
- 关于Unity中如何判断一个动画播放结束
方法一(强力推荐): 在动画结束帧或其他帧处加个动画事件,在播放到这一帧的时候会自动调用这个动画函数 如图,找到对应动画的inspector面板,在里面有个Events下拉条,下拉后在想要的帧的位置添 ...
- Window环境下搭建android NDK开发环境
1.下载ndk和cygwin NDK 下载地址:http://developer.android.com/tools/sdk/ndk/index.html Cygwin 下载地址:http://cyg ...
- wifi 通过omnipeek 查看 pmf是否生效
给android的wifi设备添加PMF支持时,抓取omnipeek分析. 从assoc req 中发现相关标志位没有使能,说明STA 没有使能PMF RSN Capabilities: %00000 ...
- CentOS 7 之前好好的,突然一天启动时黑屏,没有登陆界面了(配置 network-scripts 连网)
原因: 百度大神说是Gnome(一套纯粹自由的计算机软件,运行在操作系统上,提供图形桌面环境)不行了. 解决方法: 1. 重启系统,ctrl + alt + F2 进入命令行界面. 2. sudo s ...
- asp 读文件 比较ip
<% Dim UserIPAddress Set UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR" ...
- resharper安装后,F12不能转到定义,也不是反编译,而是转到对象浏览器(object browser)
问: resharper安装后,一不小心点错了(选择了object browser)以上配置在哪里设置?转到定义用习惯了. 回答 :打开Resharper,选择Options,然后选择Tools中的E ...
- Saltstack配置管理(2)
1.SaltStack批量安装zabbix_agent端. vim /etc/salt/states/init/zabbix_agnet.sls zabbix_install.conf: pkg.in ...
- 写一个方法,用一个for循环打印九九乘法表
public class MultiplicationTable { /** * @description 写一个方法,用一个for循环打印九九乘法表 * @author wangkun * ...
- 通过tarball形式安装HBASE Cluster(CDH5.0.2)——如何配置分布式集群中的zookeeper
集群安装总览参见这里 Zookeeper的配置 1,/etc/profile中加入zk的路径设置,见上面背景说明. 2,进入~/zk/conf目录,复制zoo_sample.cfg为zoo.cfg v ...