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的更多相关文章
随机推荐
- 【转】Grafana系列教程–Grafana基本概念
在上面几篇文章中,我们介绍了Grafana的安装配置以及运行的方法,本篇文章我们就来介绍下Grafana的基本概念. 一.Data Source — 数据源 Grafana支持多种不同的时序数据库数据 ...
- 初学Android的几个常见问题
1.关于开发环境搭配,可以到网站http://developer.android.com/sdk/index.html下载adt-bundle-windows-x86-20131030.zip,里面包 ...
- WEB打印(jsp版)
<%@ page contentType="text/html; charset=UTF-8" language="java"%> <%@in ...
- android学习中遇到的错误
1.运行项目的时候报错: [2013-12-16 17:59:22 - Dex Loader] Unable to execute dex: java.nio.BufferOverflowExcept ...
- 在Unity场景中更改天空盒的步骤
一.介绍 目的:在Unity场景中制作一个天空盒. 软件环境:Unity 2017.3.0f3,VS2013. 参考 skybox 二.自制一个天空盒 1,创建一个材质material 2,更改属性为 ...
- Eclipse初次java开发问题总结-3
上篇中提到解决的一个问题是mysql驱动报的: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link ...
- e797. 显示JSlider的标记
The slider supports two levels of tick marks, major and minor. Typically, the minor tick-mark spacin ...
- 回想sql语句中的各种连接
1. 内连接(Inner Join) 内连接是最常见的一种连接,它页被称为普通连接,而E.FCodd最早称之为自然连接. 以下是ANSI SQL-92标准 select * from t_ins ...
- Java Decompiler Plugin For Eclipse IDE
1. 下载JAD , 1.5.8版本的jad在 http://www.softpedia.com/progDownload/JAD-Download-85911.html 将展开后的jad.exe放到 ...
- k8s sidecar, Ambassador, Adapter containers
When you start thinking in terms of Pods, there are naturally some general patterns of modular appli ...