//EnumFlags.cs
using UnityEngine;
///<summary> ///定义多选属性 ///</summary> public class EnumFlags : PropertyAttribute{}
//EnumFlagsDrawer.cs
using UnityEngine;
using UnityEditor;
///<summary> ///绘制多选属性 ///</summary> [CustomPropertyDrawer(typeof(EnumFlags))] public class EnumFlagsDrawer : PropertyDrawer { public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { property.intValue = EditorGUI.MaskField(position, label, property.intValue, property.enumNames); } }
//在需要多选的枚举变量的声明上加上EnumFlags属性标签,如:
[Hear("这里是标题")]
[EnumFlags] //这里是EnumFlags属性标签
public EnumType enumType;
效果如图