public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { vEnumFlagAttribute flagSettings = (vEnumFlagAttribute)attribute; string propName = flagSettings.enumName; if (string.IsNullOrEmpty(propName)) { propName = property.displayName; } if (property.propertyType == SerializedPropertyType.Enum) { EditorGUI.BeginProperty(position, label, property); property.intValue = EditorGUI.MaskField(position, propName, property.intValue, Enum.GetNames(fieldInfo.FieldType)); EditorGUI.EndProperty(); } else { EditorGUI.PropertyField(position, property, property.hasChildren); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { vEnumFlagAttribute flagSettings = (vEnumFlagAttribute)attribute; Enum targetEnum = GetBaseProperty <Enum>(property); string propName = flagSettings.enumName; if (string.IsNullOrEmpty(propName)) { propName = property.displayName; } EditorGUI.BeginProperty(position, label, property); #if UNITY_2017_1_OR_NEWER Enum enumNew = EditorGUI.EnumFlagsField(position, propName, targetEnum); #else Enum enumNew = EditorGUI.EnumMaskField(position, propName, targetEnum); #endif property.intValue = (int)Convert.ChangeType(enumNew, targetEnum.GetType()); EditorGUI.EndProperty(); }