Files
BABA_YAGA/Assets/Scripts/Player/MeleeWeapon/Editor/vEnumFlagDrawer.cs

30 lines
1.0 KiB
C#
Raw Normal View History

2026-05-30 09:16:35 +07:00
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);
}
}
}