Unity之EditorGUILayout-枚举

转载:http://blog.csdn.net/liqiangeastsun/article/details/42173105
枚举类型和 系统自带的 静态Mask枚举
枚举可以自己定义,EnumMaskField则是系统定义好的,有如下几类值

Unity之EditorGUILayout-枚举_第1张图片

options 是枚举
static Flags 是EnumMaskField
该脚本拖拽到对象上


using UnityEngine;  
using System.Collections;  
using UnityEditor;  
  
public enum OPTIONS {   
    CUBE = 0,  
    SPHERE,  
    PLANE,  
}  
  
public class Test : MonoBehaviour {  
    public OPTIONS options = OPTIONS.PLANE;  
    public float number;  
    public StaticEditorFlags staticFlagMask = 0;  
}  

InspectorTest脚本放在Editor文件夹下

**[csharp]** [view plain](http://blog.csdn.net/liqiangeastsun/article/details/42173105#) [copy](http://blog.csdn.net/liqiangeastsun/article/details/42173105#)

using UnityEngine;  
using System.Collections;  
using UnityEditor;  
  
  
[CustomEditor(typeof(Test))]  
public class InspectorTest : Editor {  
  
    public override void OnInspectorGUI()  
    {  
        Test myTest = (Test)target;  
        myTest.options = (OPTIONS)EditorGUILayout.EnumPopup("options", myTest.options);  
        myTest.number = EditorGUILayout.FloatField("number", myTest.number);  
        myTest.staticFlagMask = (StaticEditorFlags)EditorGUILayout.EnumMaskField("static Flags", myTest.staticFlagMask);       
    }  
}  

你可能感兴趣的:(Unity之EditorGUILayout-枚举)