30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using System;
|
|
using System.Reflection;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Invector
|
|
{
|
|
[CustomPropertyDrawer(typeof(vEnumFlagAttribute))]
|
|
public class vEnumFlagDrawer : PropertyDrawer
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
} |