Class ReflectionUtil
A utility class providing reflection helper methods.
Inherited Members
Namespace: IPA.Utilities
Assembly: IPA.Loader.dll
Syntax
public static class ReflectionUtil
Methods
| Improve this Doc View SourceCopyComponent(Component, Type, GameObject, Type)
Copies a component original
to a component of overridingType
on the destination UnityEngine.GameObject.
Declaration
public static Component CopyComponent(this Component original, Type overridingType, GameObject destination, Type originalTypeOverride = null)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Component | original | the original component |
Type | overridingType | the new component's type |
UnityEngine.GameObject | destination | the destination GameObject |
Type | originalTypeOverride | overrides the source component type (for example, to a superclass) |
Returns
Type | Description |
---|---|
UnityEngine.Component | the copied component |
CopyComponent<T>(Component, GameObject, Type)
A generic version of CopyComponent(Component, Type, GameObject, Type).
Declaration
public static T CopyComponent<T>(this Component original, GameObject destination, Type originalTypeOverride = null)
where T : Component
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Component | original | the original component |
UnityEngine.GameObject | destination | the destination game object |
Type | originalTypeOverride | overrides the source component type (for example, to a superclass) |
Returns
Type | Description |
---|---|
T | the copied component |
Type Parameters
Name | Description |
---|---|
T | the overriding type |
See Also
| Improve this Doc View SourceGetField<T>(Object, String)
Gets the value of a field.
Declaration
public static T GetField<T>(this object obj, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | the object instance to pull from |
String | fieldName | the name of the field to read |
Returns
Type | Description |
---|---|
T | the value of the field |
Type Parameters
Name | Description |
---|---|
T | the type of the field (result casted) |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
GetField<T, U>(U, String)
Gets the value of a field.
Declaration
public static T GetField<T, U>(this U obj, string fieldName)
Parameters
Type | Name | Description |
---|---|---|
U | obj | the object instance to pull from |
String | fieldName | the name of the field to read |
Returns
Type | Description |
---|---|
T | the value of the field |
Type Parameters
Name | Description |
---|---|
T | the type of the field (result casted) |
U | the type to get the field from |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
InvokeMethod(Object, String, Object[])
Invokes a method on an object.
Declaration
public static object InvokeMethod(this object obj, string methodName, params object[] methodArgs)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | the object to call from |
String | methodName | the method name |
Object[] | methodArgs | the method arguments |
Returns
Type | Description |
---|---|
Object | the return value |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
InvokeMethod<T>(T, String, Object[])
Invokes a method from T
on an object.
Declaration
public static object InvokeMethod<T>(this T obj, string methodName, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
T | obj | the object instance |
String | methodName | the method's name |
Object[] | args | the method arguments |
Returns
Type | Description |
---|---|
Object | the return value |
Type Parameters
Name | Description |
---|---|
T | the type to search for the method on |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
InvokeMethod<T>(Object, String, Object[])
Invokes a method.
Declaration
public static T InvokeMethod<T>(this object obj, string methodName, params object[] methodArgs)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | the object instance |
String | methodName | the method name to call |
Object[] | methodArgs | the method's arguments |
Returns
Type | Description |
---|---|
T | the return value |
Type Parameters
Name | Description |
---|---|
T | the return type |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
See Also
| Improve this Doc View SourceInvokeMethod<T, U>(U, String, Object[])
Invokes a method from U
on an object.
Declaration
public static T InvokeMethod<T, U>(this U obj, string methodName, params object[] methodArgs)
Parameters
Type | Name | Description |
---|---|---|
U | obj | the object instance |
String | methodName | the method name to call |
Object[] | methodArgs | the method's arguments |
Returns
Type | Description |
---|---|
T | the return value |
Type Parameters
Name | Description |
---|---|
T | the return type |
U | the type to search for the method on |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
See Also
| Improve this Doc View SourceSetField(Object, String, Object)
Sets a field on the target object.
Declaration
public static void SetField(this object obj, string fieldName, object value)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | the object instance |
String | fieldName | the field to set |
Object | value | the value to set it to |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
SetField<T>(T, String, Object)
Sets a field on the target object, as gotten from T
.
Declaration
public static void SetField<T>(this T obj, string fieldName, object value)
Parameters
Type | Name | Description |
---|---|---|
T | obj | the object instance |
String | fieldName | the field to set |
Object | value | the value to set it to |
Type Parameters
Name | Description |
---|---|
T | the type to get the field from |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
SetProperty(Object, String, Object)
Sets a property on the target object.
Declaration
public static void SetProperty(this object obj, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | the target object instance |
String | propertyName | the name of the property |
Object | value | the value to set it to |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |
SetProperty<T>(T, String, Object)
Sets a property on the target object, as gotten from T
Declaration
public static void SetProperty<T>(this T obj, string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
T | obj | the object instance |
String | propertyName | the property to set |
Object | value | the value to set it to |
Type Parameters
Name | Description |
---|---|
T | the type to get the property from |
Exceptions
Type | Condition |
---|---|
ArgumentException | if |