ScriptableWizard 脚本化向导

Inherits from EditorWindow

Derive from this class to create an editor wizard.


Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。

Editor wizards are typically opened using a menu item.


// C#
// Creates a simple wizard that lets you create a Light GameObject
// or if the user clicks in "Apply", it will set the color of the currently
// object selected to red

using UnityEditor;
using UnityEngine;

class WizardCreateLight : ScriptableWizard {
	public float range = 500;
	public Color color =;

	[MenuItem ("GameObject/Create Light Wizard")]
	static void CreateWizard () {
		ScriptableWizard.DisplayWizard<WizardCreateLight>("Create Light", "Create", "Apply");
		//If you don't want to use the secondary button simply leave it out:
		//ScriptableWizard.DisplayWizard<WizardCreateLight>("Create Light", "Create");
	void OnWizardCreate () {
		GameObject go = new GameObject ("New Light");
		go.light.range = range;
		go.light.color = color;
	void OnWizardUpdate () {
		helpString = "Please set the color of the light!";
	// When the user pressed the "Apply" button OnWizardOtherButton is called.
	void OnWizardOtherButton () {
		if (Selection.activeTransform == null ||
			Selection.activeTransform.light == null) return;
		Selection.activeTransform.light.color =;


Messages Sent发送消息

Class Functions类函数

Inherited members继承成员

Inherited Variables继承变量

Inherited Functions继承函数

Inherited Variables继承变量

Inherited Class Functions继承类函数

Inherited Messages Sent继承发送消息

Page last updated: 2011-8-20