Editor类的多选枚举

using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomPropertyDrawer(typeof(EnumFlags))]


public class EnumFlagsEditor : PropertyDrawer {


    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        property.intValue = EditorGUI.MaskField(position, label, property.intValue, property.enumNames);
    }

}



using UnityEngine;
using System.Collections;


public class EnumFlags : PropertyAttribute
{




}



using UnityEngine;
using System.Collections;


public class EnumTest : MonoBehaviour
{


   
    public enum Enemy { 暗夜精灵,亡灵,兽人,人类}


    [EnumFlags]
    public Enemy enemy;


}


把EnumTest.cs脚本挂在GameObject上

你可能感兴趣的:(Unity)