using UnityEditor; using System; using System.Reflection; namespace NaughtyAttributes.Editor { public static class PropertyUtility { public static T GetAttribute(SerializedProperty property) where T : Attribute { T[] attributes = GetAttributes(property); return attributes.Length > 0 ? attributes[0] : null; } public static T[] GetAttributes(SerializedProperty property) where T : Attribute { FieldInfo fieldInfo = ReflectionUtility.GetField(GetTargetObject(property), property.name); return (T[])fieldInfo.GetCustomAttributes(typeof(T), true); } public static UnityEngine.Object GetTargetObject(SerializedProperty property) { return property.serializedObject.targetObject; } } }