I want custom a enum mask property using PropertyDrawer, I can not find EnumValue from SerializedProperty class, so I use property.enumValueIndex with EditorGUILayout.MaskField, but when I set back the value to property.enumValueIndex, it raise a error:
enum index is out of range
UnityEditor.SerializedProperty:set_enumValueIndex(Int32)
[CustomPropertyDrawer(typeof(EnumMaskAttribute))]
internal sealed class EnumMaskDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EnumMaskAttribute attribute = (EnumMaskAttribute)base.attribute;
if (property.propertyType == SerializedPropertyType.Enum)
{
property.enumValueIndex = EditorGUILayout.MaskField(label, property.enumValueIndex, property.enumNames);
}
else
{
EditorGUI.LabelField(position, label.text, "Use Range with float or int.");
}
}
}
Is any body has this problem, and how to solve it, or how do I custom the Enum mask property?