Editor 编辑器

Inherits from ScriptableObject

Base class to derive custom Editors from. Use this to create your own custom inspectors and editors for your objects.

派生的自定义编辑器基类。使用这个为你的对象来创建自己的自定义检视面板和编辑器。

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"引用。

You can attach the Editor to a custom component by using the CustomEditor attribute.

你可以附加该编辑器到一个自定义组件,通过使用CustomEditor属性。

JavaScript Example:

// This example shows a custom inspector for an

// object "MyPlayerEditor", which has two variables, vel (velocity) and ammo.

//显示一个对象MyPlayerEditor的自定义检视面板,其中有两个变量vel (velocity) 和 ammo

@CustomEditor(MyPlayerEditor)

class MyPlayerEditor extends Editor {

	function OnInspectorGUI() {

		EditorGUILayout.BeginHorizontal ();

		EditorGUILayout.PrefixLabel ("Speed");

		target.vel = EditorGUILayout.Slider(target.vel, 0, 100);

		EditorGUILayout.EndHorizontal ();



		EditorGUILayout.BeginHorizontal ();

		EditorGUILayout.PrefixLabel ("Ammo");

		target.ammo = EditorGUILayout.IntField(target.ammo);

		EditorGUILayout.EndHorizontal ();

	}

}

Variables变量

Functions函数

Messages Sent发送消息

Inherited members继承成员

Inherited Variables继承变量

Inherited Functions继承函数

Inherited Class Functions继承类函数

Inherited Messages Sent继承发送消息

Page last updated: 2011-6-28