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 ();
}
}