docs.unity3d.com
    Show / Hide Table of Contents

    Class SerializedPropertyHelper

    Helpers for the editor relating to SerializedPropertys

    Inheritance
    Object
    SerializedPropertyHelper
    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
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023