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的更多相关文章
随机推荐
- ZARM in Linux & MIUI
zram是Linux内核的一个模块,之前被称为“compcache”.zram通过在RAM内的压缩快设备上分页,直到必须使用硬盘上的交换空间,以避免在磁盘上进行分页,从而提高性能.由于zram可以用内 ...
- EasyUI 验证
使用过程中的一积累,备查. EasyUI 验证框使用方法://***************************missingMessage:未填写时显示的信息validType:验证类型见下示例 ...
- vb.net与c#相互转换工具
vb.net与c#相互转换工具: http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx http://www.dotne ...
- elasticsearch系列六:聚合分析(聚合分析简介、指标聚合、桶聚合)
一.聚合分析简介 1. ES聚合分析是什么? 聚合分析是数据库中重要的功能特性,完成对一个查询的数据集中数据的聚合计算,如:找出某字段(或计算表达式的结果)的最大值.最小值,计算和.平均值等.ES作为 ...
- Java如何显示线程状态?
在Java编程中,如何显示线程状态? 以下示例演示如何使用Thread类的isAlive()和getStatus()方法显示线程的不同状态. package com.yiibai; class MyT ...
- e798. 显示JSlider的标记标签
This example demonstrates how to display labels (numerical values) at the major ticks (see e797 显示JS ...
- Unity----Scene加载问题
Unity官方提供了4种加载场景(scene)的方法,分别是: 1. Application.LoadLevel():同步加载 2. Application.LoadLevelAsync():异步加载 ...
- (转) s-video vs. composite video vs. component video 几种视频格式详细说明和比较
之前对着几种视频格式认识不是很清晰,所以看数据手册的时候,看的也是稀里糊涂的. 因为项目中需要用到cvbs做视频输入,在元器件选型上,看到tw2867的数据手册上,有这么一句话: The TW2867 ...
- ubuntu14.04安装好用的google拼音输入法
装了ubuntu14.04后感觉自带的拼音输入法不好用的有没有,有些字拼不出来有没有...,其实我们安装google拼音输入发就会好很多... 方法/步骤 安装google拼音输入法 $sud ...
- hibernate 中的session和事务(Transaction)
在使用hibernate开发时,遇到最多的就是session与事务,那么他们两个有什么关系呢?下面我来抛砖引玉: 1.session是hibernate中的以及缓存机制,是用来对数据进行增删改查的一个 ...