Class SerializedPropertyHelper
Helpers for the editor relating to SerializedPropertys
Namespace: Cinemachine.Editor
Syntax
public static class SerializedPropertyHelper
Methods
FindProperty(SerializedObject, Expression<Func<Object>>)
A compiler-assisted (non-string-based) way to call SerializedProperty.FindProperty
Declaration
public static SerializedProperty FindProperty(this SerializedObject obj, Expression<Func<object>> exp)
Parameters
Type | Name | Description |
---|---|---|
SerializedObject | obj | The serialized object to search |
Expression<Func<Object>> | exp | Magic expression that resolves to a field: () => myClass.m_MyField |
Returns
Type | Description |
---|---|
SerializedProperty | The resulting SerializedProperty, or null |
FindPropertyRelative(SerializedProperty, Expression<Func<Object>>)
A compiler-assisted (non-string-based) way to call SerializedProperty.FindPropertyRelative
Declaration
public static SerializedProperty FindPropertyRelative(this SerializedProperty obj, Expression<Func<object>> exp)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | obj | The serialized object to search |
Expression<Func<Object>> | exp | Magic expression that resolves to a field: () => myClass.m_MyField |
Returns
Type | Description |
---|---|
SerializedProperty | The resulting SerializedProperty, or null |
GetPropertyValue(SerializedProperty)
Get the value of a proprty, as an object
Declaration
public static object GetPropertyValue(SerializedProperty property)
Parameters
Type | Name | Description |
---|---|---|
SerializedProperty | property | The property to query |
Returns
Type | Description |
---|---|
Object | The object value of the property |
PropertyName(Expression<Func<Object>>)
This is a way to get a field name string in such a manner that the compiler will generate errors for invalid fields. Much better than directly using strings. Usage: instead of
"m_MyField";
do this:
MyClass myclass = null;
SerializedPropertyHelper.PropertyName( () => myClass.m_MyField);
Declaration
public static string PropertyName(Expression<Func<object>> exp)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<Object>> | exp | Magic expression that resolves to a field: () => myClass.m_MyField |
Returns
Type | Description |
---|---|
String |