using System;
using UnityEditor;

[TypeDrawer]
public class EnumTypeDrawer : ITypeDrawer
{
    public bool HandlesType(Type type, object value)
    {
        return type.IsEnum;
    }

    public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target)
    {
        if (memberType.IsDefined(typeof(FlagsAttribute), false))
        {
            return EditorGUILayout.EnumFlagsField(memberName, (Enum)value);
        }

        return EditorGUILayout.EnumPopup(memberName, (Enum)value);
    }

    public void Destroy()
    {
    }
}