Show / Hide Table of Contents

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
Object
VariaReflection
Namespace: Varia
Assembly: cs.temp.dll.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
Type Description
VariaMirror

EvalExpressionOrThrow(Type, String)

Declaration
public static VariaMirror EvalExpressionOrThrow(Type targetType, string expression)
Parameters
Type Name Description
Type targetType
String expression
Returns
Type Description
VariaMirror

GetProperties(Type)

Declaration
public static List<VariaProperty> GetProperties(Type targetType)
Parameters
Type Name Description
Type targetType
Returns
Type Description
List<VariaProperty>

GetValue(Object, String)

Declaration
public static object GetValue(object o, string expression)
Parameters
Type Name Description
Object o
String expression
Returns
Type Description
Object

SetValue(Object, String, Object)

Declaration
public static void SetValue(object o, string expression, object value)
Parameters
Type Name Description
Object o
String expression
Object value
Back to top Generated by DocFX