Class VariaReflection
VariaReflection is a simplified version of C# reflection, with an emphasis on reading and writing.
The main feature is given a expression, it lets you read and write values for the field corresponding to that expression.
An expression is build as follows:
expression ::= property_name |
property_name "." expression |
"propertyBlock" "." material_property_name "." type
The first form indicates a property of the target object itself.
The second form evaluates the sub-expression on the value of named property of the target object.
The third form corresponds to Renderer.SetPropertyBlock (https://docs.unity3d.com/ScriptReference/Renderer.SetPropertyBlock.html)
Material property block properties behave particularly strangely:
- They must have the type encoded in the name as it's not available at runtime.
- They are not listed when exploring the properties of an object (though you can use VariaMaterialPropertyBlockReflection to get them)
Inheritance
VariaReflection
Namespace: Varia
Assembly: Varia.dll
Syntax
public static class VariaReflection
Methods
EvalExpression(Type, string)
Declaration
public static VariaMirror EvalExpression(Type targetType, string expression)
Parameters
Type |
Name |
Description |
Type |
targetType |
|
string |
expression |
|
Returns
EvalExpressionOrThrow(Type, string)
Declaration
public static VariaMirror EvalExpressionOrThrow(Type targetType, string expression)
Parameters
Type |
Name |
Description |
Type |
targetType |
|
string |
expression |
|
Returns
GetProperties(Type)
Declaration
public static List<VariaProperty> GetProperties(Type targetType)
Parameters
Type |
Name |
Description |
Type |
targetType |
|
Returns
GetValue(object, string)
Declaration
public static object GetValue(object o, string expression)
Parameters
Returns
SetValue(object, string, object)
Declaration
public static void SetValue(object o, string expression, object value)
Parameters