Wanzyee Studio
PropertyValueExtension

Extension methods for UnityEditor.SerializedProperty using VariableInfo. More...

Static Public Member Functions

static VariableInfo[] GetVariableParents (this SerializedProperty property)
 Get VariableInfo hierarchy by specified UnityEditor.SerializedProperty. More...
 
static VariableInfo GetVariableInfo (this SerializedProperty property)
 Get a VariableInfo by specified UnityEditor.SerializedProperty. More...
 
static Type GetValueType (this SerializedProperty property)
 Get the type of the property's value. More...
 
static object GetValue (this SerializedProperty property)
 Get the value of the property. More...
 
static void SetValue (this SerializedProperty property, object value)
 Set the value of the property with recording undo. More...
 
static object GetDeclarer (this SerializedProperty property)
 Get the instance which declares the specified UnityEditor.SerializedProperty. More...
 

Detailed Description

Extension methods for UnityEditor.SerializedProperty using VariableInfo.

Work with System.Reflection to access values. Basically okay for user defined fields, and script properties aren't serializable. Depend on SerializedProperty.propertyPath with exactly the same name to find reflection. But might error with built-in types. E.g., UnityEngine.Bounds has path "m_Extent" but field "m_Extents" and property "extents".

Member Function Documentation

static VariableInfo [] GetVariableParents ( this SerializedProperty  property)
static

Get VariableInfo hierarchy by specified UnityEditor.SerializedProperty.

Steps to reflect from serialized target object to the field the property points to. This works by reflection.

Parameters
propertyProperty.
Returns
The hierarchy VariableInfo array.
static VariableInfo GetVariableInfo ( this SerializedProperty  property)
static

Get a VariableInfo by specified UnityEditor.SerializedProperty.

The VariableInfo reflects to the field the property point to. This works by reflection.

Parameters
propertyProperty.
Returns
The VariableInfo.
static Type GetValueType ( this SerializedProperty  property)
static

Get the type of the property's value.

This works by reflection.

Parameters
propertyProperty.
Returns
The type.
static object GetValue ( this SerializedProperty  property)
static

Get the value of the property.

When a property editing multi target, return the first value. This works by reflection.

Parameters
propertyProperty.
Returns
The value.
static void SetValue ( this SerializedProperty  property,
object  value 
)
static

Set the value of the property with recording undo.

This works by reflection, but available for struct. When a property of reference type value editing multi targets. This will assign the same value instance without cloning.

Parameters
propertyProperty.
valueValue.
static object GetDeclarer ( this SerializedProperty  property)
static

Get the instance which declares the specified UnityEditor.SerializedProperty.

Parameters
propertyProperty.
Returns
Instance.