Version 3.3.1.0

FieldExpressionContext struct

Namespace: Sirenix.Utilities.Editor
Assembly: Sirenix.Utilities.Editor
public struct FieldExpressionContext
Type containing the necessary components to use C# expressions in fields.
Example
// Creating and using a context with for a static type. FieldExpressionContext context = FieldExpressionContext.StaticExpression(typeof(MyStaticType)); SirenixEditorFields.SmartIntField(context, ...);
Example
// Creating and using a context with an instanced type. FieldExpressionContext context = FieldExpressionContext.InstanceContext(myInstance); SirenixEditorFields.SmartIntField(context, ...);
Example
// Creating and using context with an InspectorProperty, for example, in a custom Odin drawer. FieldExpressionContext context = property.ToFieldExpressionContext(); SirenixEditorFields.SmartIntField(context, ...);

Fields

Instance
Target instance for field expressions.
public readonly object Instance
Type
Target type for expressions.
public readonly Type Type

Properties

IsStatic
Indicates if the expressions targets a static type or not.
public bool IsStatic { get; }

Methods

InstanceContext(Object)
Creates an expression context that targets the provided instance. Expression can access members of the instance.
public static FieldExpressionContext InstanceContext(object instance)
Parameters
System.Object instance

The instance for the context to target.

Returns
FieldExpressionContext

FieldExpressionContext that targets an instance.

Exceptions
System.ArgumentNullException

Throws if instance is null.

None()
Creates an expression context that targets nothing. Expressions are still possible, but no members can be accessed, and only static method can be called.
public static FieldExpressionContext None()
Returns
FieldExpressionContext

FieldExpresionContext target targets nothing.

StaticContext(Type)
Creates an expression context that targets the provided type. Only static members can be accessed.
public static FieldExpressionContext StaticContext(Type type)
Parameters
System.Type type

The type to target.

Returns
FieldExpressionContext

FieldExpressionContext that targets a static type.

Exceptions
System.ArgumentNullException

Throws if type is null.