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
//创建一个简单的向导,来创建灯光物体
//或如果用户点击"Apply",它将设置当前选择的物体颜色为红色
using UnityEditor;
using UnityEngine;
class WizardCreateLight : ScriptableWizard {
public float range = 500;
public Color color = Color.red;
[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.AddComponent("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.
//当用户按下"Apply"按钮,OnWizardOtherButton被调用
void OnWizardOtherButton () {
if (Selection.activeTransform == null ||
Selection.activeTransform.light == null) return;
Selection.activeTransform.light.color = Color.red;
}
}
Variables变量
-
Allows you to set the help text of the wizard.
允许您设置向导的帮助文本。 -
Allows you to set the error text of the wizard.
允许您设置向导的错误文本。 -
Allows you to enable and disable the wizard create button, so that the user can not click it.
允许您启用和禁用向导创建按钮,以便用户不能点击。
Messages Sent发送消息
-
This is called when the wizard is opened or whenever the user changes something in the wizard.
当向导被打开或只要用户在向导改变了某些东西时被调用。 -
This is called when the user clicks on the Create button.
当用户在创建按钮上点击是调用。 -
Called every frame when the wizard is visible.
当向导可见时每帧调用。 -
Allows you to provide an action when the user clicks on the other button.
当用户在其他按钮点击时,允许您提供一个动作。
Class Functions类函数
-
Creates a wizard. // 创建一个向导。
-
Creates a wizard. // 创建一个向导。
Inherited members继承成员
Inherited Variables继承变量
-
Does the GUI in this editor window want MouseMove events?
GUI在这个编辑器窗口是否想要MouseMove事件? -
Does the window automatically repaint whenever the scene has changed?
每当场景改变,窗口自动重绘? -
The position of the window in screen space.
窗口在屏幕空间的位置。
-
The name of the object. //物体的名字
-
Should the object be hidden, saved with the scene or modifiable by the user?
物体是否被隐藏、保存在场景中或被用户修改?
Inherited Functions继承函数
-
Mark the beginning area of all popup windows.
标记所有弹出窗口的开始区域。 -
Close a window group started with EditorWindow.BeginWindows
关闭一个开始于EditorWindow.BeginWindows的窗口组。 -
Show a notification message.
显示一个通知消息。 -
Stop showing notification message.
停止显示通知消息。 -
显示Tab
-
Moves keyboard focus to this EditorWindow.
移动键盘焦点到这个编辑器窗口。 -
Show the EditorWindow as a floating utility window.
显示编辑器窗口,作为一个浮动工具窗口。 -
Used for popup style windows.
用于弹出类型窗口。 -
Show the EditorWindow.
显示编辑器窗口。 -
Show the editor window in the auxiliary window.
在辅助窗口中显示编辑器窗口。 -
Close the editor window.
关闭编辑器窗口。 -
Make the window repaint.
使窗口重绘。 -
Sends an Event to a window.
发送一个事件到窗口。
-
Returns the instance id of the object.
返回物体的实例ID -
Returns the name of the game object.
返回游戏物体的名称。
Inherited Variables继承变量
-
The EditorWindow which currently has keyboard focus (Read Only)
当前的哪一个编辑器窗口具有键盘焦点(只读)。 -
The EditorWindow currently under the mouse cursor (Read Only)
鼠标指针在当前的编辑器窗口之上(只读)。
Inherited Class Functions继承类函数
-
Returns the first EditorWindow of type t which is currently on the screen.
返回屏幕上类型t的当前的第一个编辑器窗口。 -
Returns the first EditorWindow of type T which is currently on the screen.
返回屏幕上类型T的当前的第一个编辑器窗口。 -
Focuses the first found EditorWindow of specified type if it is open.
如果是窗口打开的,焦点首先发现的指定类型的编辑器窗口。 -
Focuses the first found EditorWindow of type T if it is open.
如果是窗口打开的,焦点首先发现的类型T的编辑器窗口。 -
Returns the first EditorWindow of type t which is currently on the screen.
返回屏幕上当前类型t的第一个编辑器窗口。 -
Returns the first EditorWindow of type t which is currently on the screen.
-
Creates an instance of a scriptable object with className.
创建一个名为className的脚本化对象的一个实例。 -
Creates an instance of a scriptable object with T.
创建一个带有T参数脚本化对象的实例。
-
Does the object exist?
物体是否存在? -
Clones the object original and returns the clone.
克隆原始物体,并返回克隆的物体 -
-
Removes a gameobject, component or asset.
删除一个游戏物体、组件或资源 -
Destroys the object obj immediately. It is strongly recommended to use Destroy instead.
立即销毁物体obj,强烈建议使用Destroy代替。 -
Returns a list of all active loaded objects of Type type.
返回Type类型的所有激活的加载的物体列表 -
Returns the first active loaded object of Type type.
返回Type类型第一个激活的加载的物体。 -
Compares if two objects refer to the same
比较如果两个物体相同 -
Compares if two objects refer to a different object
比较如果两个物体不同 -
Makes the object target not be destroyed automatically when loading a new scene.
加载新场景的时候使目标物体不被自动销毁。
Inherited Messages Sent继承发送消息
-
Implement your own editor GUI here.
在这里实现自己的编辑器界面。 -
Called 100 times per second on all visible windows.
在所有可见的窗口每秒调用100次。 -
OnInspectorUpdate is called at 10 frames per second to give the inspector a chance to update
OnInspectorUpdate被调用,在给定检视面板每秒10帧更新。 -
OnDestroy is called when the EditorWindow is closed.
当编辑器窗口关闭时,OnDestroy被调用。 -
Called whenever the selection has changed.
只要选择发生改变时调用。 -
Called when the window gets keyboard focus.
当窗口获得键盘焦点时调用。 -
Called when the window loses keyboard focus.
当窗口失去键盘焦点时调用。 -
Called whenever the scene hierarchy has changed.
只要场景层级改变时调用。 -
Called whenever the project has changed.
只要项目被改变时调用。
-
Creates an instance of a scriptable object with T.
创建一脚本化对象T的一个实例。 -
This function is called when the scriptable object goes out of scope
当脚本化对象超出范围时调用这个函数。 -
This function is called when the scriptable object will be destroyed.
当脚本化对象将被销毁,这个函数被调用。
最后修改:2011年8月20日 Saturday 18:37