您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

27 行
837 B

using UnityEditor;
using System;
using System.Reflection;
namespace NaughtyAttributes.Editor
{
public static class PropertyUtility
{
public static T GetAttribute<T>(SerializedProperty property) where T : Attribute
{
T[] attributes = GetAttributes<T>(property);
return attributes.Length > 0 ? attributes[0] : null;
}
public static T[] GetAttributes<T>(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;
}
}
}