class MAGES::Editor::Utilities::SerializedObjectExtensions

Overview

Extensions for SerializedObject class. More…

class SerializedObjectExtensions
{
public:
    // classes

    class PropertyFieldCallbackListener;

    // methods

    static SerializedProperty FindFieldProperty(
        this SerializedObject serializedObject,
        string fieldName
    );

    static void CopyPropertyValue(
        SerializedProperty source,
        SerializedProperty destination
    );

    static string[] PropertyPathParts(this SerializedProperty property);
    static string FixedPropertyPath(this SerializedProperty property);

    static FieldInfo GetFieldUnambiguous(
        this Type type,
        string name,
        BindingFlags flags
    );

    static bool IsPropertyIndexer(
        string propertyPart,
        out string fieldName,
        out int index
    );

    static object GetUnderlyingValue(this SerializedProperty property);
    static void SetUnderlyingValue(this SerializedProperty property, object value);
    static object DeepCopy(object other);
};

Detailed Documentation

Extensions for SerializedObject class.

Methods

static SerializedProperty FindFieldProperty(
    this SerializedObject serializedObject,
    string fieldName
)

Finds a serialized property field.

In order to find the property it must be serialized with [field: SerializeField] attribute.

Parameters:

serializedObject

The SerializedObject to search on.

fieldName

The field name.

Returns:

The serialized property found.

static void CopyPropertyValue(
    SerializedProperty source,
    SerializedProperty destination
)

Copies the value of a serialized property to another serialized property.

Parameters:

source

The property to copy from.

destination

The property to copy to.

static string[] PropertyPathParts(this SerializedProperty property)

Splits a property path into its parts.

Parameters:

property

The property.

Returns:

Array of paths.

static string FixedPropertyPath(this SerializedProperty property)

Fixes the property path for an array to remove the “Array.data” part.

Parameters:

property

The property.

Returns:

The fixed property.

static FieldInfo GetFieldUnambiguous(
    this Type type,
    string name,
    BindingFlags flags
)

Gets a field from a type, ignoring the base types.

Parameters:

type

The type.

name

The name.

flags

Fields to look for.

Returns:

The field info.

static bool IsPropertyIndexer(
    string propertyPart,
    out string fieldName,
    out int index
)

Tests if a property part is an indexer (i.e. array).

Parameters:

propertyPart

The property part.

fieldName

The name of the field.

index

The index into the path, if it is an indexer.

Returns:

True if it is an indexer.

static object GetUnderlyingValue(this SerializedProperty property)

Gets the underlying value of a serialized property.

Parameters:

property

The property.

NullReferenceException

Thrown in the property path is invalid.

Returns:

The object value.

static void SetUnderlyingValue(this SerializedProperty property, object value)

Sets the underlying value of a serialized property.

Parameters:

property

The property.

value

The new value.

NullReferenceException

Thrown if property path is invalid.

static object DeepCopy(object other)

Returns a copy of an object that has a System.Serializable attribute.

Parameters:

other

The object to copy.

Returns:

The copy of the object.