Unity Note Editor (Curvefield, Doublefield, Enummaskfield, Enumpopup) ...

Source: Internet
Author: User

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) ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.