跳到主要内容
版本:3.0.x

Class EditorAssemblyUtility

程序集与属性工具类

Assembly: YooAsset.Editor.dll
View Source
Declaration
public static class EditorAssemblyUtility

Methods

GetAssignableTypes(Type)

获取带继承关系的所有类的类型

View Source
Declaration
public static List<Type> GetAssignableTypes(Type parentType)
Returns

System.Collections.Generic.List<System.Type>: 所有派生类型的列表

Parameters
TypeNameDescription
System.TypeparentType父类类型

GetTypesWithAttribute(Type)

获取带有指定属性的所有类的类型

View Source
Declaration
public static List<Type> GetTypesWithAttribute(Type attrType)
Returns

System.Collections.Generic.List<System.Type>: 所有带有指定属性的类型列表

Parameters
TypeNameDescription
System.TypeattrType属性类型

InvokeNonPublicStaticMethod(Type, string, params object[])

调用私有的静态方法

View Source
Declaration
public static object InvokeNonPublicStaticMethod(Type type, string method, params object[] parameters)
Returns

System.Object: 方法的返回值

Parameters
TypeNameDescription
System.Typetype类的类型
System.Stringmethod类里要调用的方法名
System.Object[]parameters调用方法传入的参数

InvokePublicStaticMethod(Type, string, params object[])

调用公开的静态方法

View Source
Declaration
public static object InvokePublicStaticMethod(Type type, string method, params object[] parameters)
Returns

System.Object: 方法的返回值

Parameters
TypeNameDescription
System.Typetype类的类型
System.Stringmethod类里要调用的方法名
System.Object[]parameters调用方法传入的参数

GetAttribute<T>(Type)

获取指定类型上的自定义属性

View Source
Declaration
public static T GetAttribute<T>(Type type) where T : Attribute
Returns

<T>: 属性实例,不存在时为 null

Parameters
TypeNameDescription
System.Typetype目标类型
Type Parameters
NameDescription
T属性类型

GetAttribute<T>(MethodInfo)

获取指定方法上的自定义属性

View Source
Declaration
public static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
Returns

<T>: 属性实例,不存在时为 null

Parameters
TypeNameDescription
System.Reflection.MethodInfomethodInfo目标方法
Type Parameters
NameDescription
T属性类型

GetAttribute<T>(FieldInfo)

获取指定字段上的自定义属性

View Source
Declaration
public static T GetAttribute<T>(FieldInfo field) where T : Attribute
Returns

<T>: 属性实例,不存在时为 null

Parameters
TypeNameDescription
System.Reflection.FieldInfofield目标字段
Type Parameters
NameDescription
T属性类型