ScriptableWizard.OnWizardCreate 当向导创建

function OnWizardCreate () : void

Description描述

This is called when the user clicks on the Create button.

当用户在创建按钮上点击是调用。

Here you perform any final creation/modification actions. After OnCreateWizard is called, the wizard is automatically closed.

在这里执行任何最终创建/修改动作。OnCreateWizard调用之后,向导自动关闭。

参见:ScriptableWizard.DisplayWizard

ScriptableWizard.OnWizardCreate 当向导创建

Scriptable Wizard window for selecting GameObjects of a certain "type".
脚本化向导窗口用于选择有一定的“类型”游戏物体。

// C#
// Editor Script that lets you "Select" all the GameObjects that have a certain Component.
//编辑器脚本让你"Select"所有带有一定组件的游戏物体,
using UnityEngine;
using UnityEditor;
using System.Collections;

public class ScriptableWizardOnWizardCreate : ScriptableWizard {
	public string componentName = "Camera";

	[MenuItem ("Example/OnWizardCreate example")]
	public static void SelectAllOfTypeMenuIem() {
		ScriptableWizard.DisplayWizard(
			"Select objects of type ...",
			typeof(ScriptableWizardOnWizardCreate),
			"Select");
	}

	void OnWizardCreate() {
		Object[] objs = FindObjectsOfType(typeof(GameObject));
		ArrayList selectionBuilder = new ArrayList();
		foreach (GameObject go in objs) {
			if(go.GetComponent(componentName))
				selectionBuilder.Add(go);
		}
		Selection.objects = selectionBuilder.ToArray(typeof(GameObject)) as GameObject[];
	}
}
最后修改:2011年6月25日 Saturday 14:21

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。