1. Curvefield
Create a curve variable of type Animationcurve, see the code:
[Code]csharpcode:
Using unityengine;using system.collections;using unityeditor; Reference to the editor namespace public class Editor2:editorwindow//editor class { private Animationcurve _animationcurve = new Animationcurve ( ); Initialize a curve [MenuItem ("Editordemo/createwindow")]//Add a menu in the editor static void CreateWindow ()//The following function must be * * * static { //In this case Create window Editorwindow.getwindow (typeof (Editor2), False, "Editorwindow", True); } void Ongui () { _animationcurve = Editorguilayout.curvefield ("Animationcurve", _animationcurve);// Create an editable curve region }}
A few things to note:
(1) When using the Curvefield function, you must first initialize the Animationcurve variable, because the value returned by the function must be stored in a place. And the function needs to know that there are several key points on this curve (key);
(2) The Animationcurve type cannot be interpreted as an animated curve from the surface meaning, but it has a great effect when defining an irregular variable, such as:
(3) The Curvefield can also change the color and constraints of the curve, this people will try on their own.
2. Doublefield
This is an input range that can enter a double type floating-point value, and the usage of Floatfield is the same, I will not repeat, directly on the code:
[Code]csharpcode:
Using unityengine;using system.collections;using unityeditor; Reference to the editor namespace public class Editor2:editorwindow//editor class { private double _doublevalue;//Declare a double variable [MenuItem ( "Editordemo/createwindow")]//Add a menu in the editor static void CreateWindow ()//The following function must be * * * static { //Create a window in this face Editorwindow.getwindow (typeof (Editor2), False, "Editorwindow", true); void Ongui () { _doublevalue = Editorguilayout.doublefield ("Doublefield", _doublevalue);//Create a double floating-point input area }}
3. Enummaskfield, Enumpopup
Enummaskfield is a multi-select enumeration selection, relative to Enumpopup, to see the code and compare:
[Code]csharpcode:
Using unityengine;using system.collections;using unityeditor; Reference to the editor namespace public class Editor2:editorwindow//editor class { private enum ENUMVALUE0//Here we declare two enum type { value0 = 0 , value1 = 1, value2 = 2 }; Private EnumValue0 _enumvalue0 = enumvalue0.value0; Private enum EnumValue1//Here we declare two enumeration types { value0 = 0, value1 = 1, value2 = 2 }; Private EnumValue1 _enumvalue1 = enumvalue1.value0; [MenuItem ("Editordemo/createwindow")]//Add a menu in the editor static void CreateWindow ()//The following function must be * * * static { //Create a window in this area Editorwindow.getwindow (typeof (Editor2), False, "Editorwindow", true); void Ongui () { _enumvalue0 = (EnumValue0) Editorguilayout.enummaskfield ("Enummaskfield", _enumvalue0);// Multiple selection, single selection, _enumvalue1 = (EnumValue1) editorguilayout.enumpopup ("Enumpopup", _enumvalue1);//Radio }}
(GO) Unity Note Editor (Curvefield, Doublefield, Enummaskfield, Enumpopup) ...