Class SerializedObject

The SerializedObject class provides functionality to create a serialized version of an object. The object must be a serializable type such as TypeScriptComponent, TypeScriptResource or any type marked with the SerializedObjectAttribute

Hierarchy

  • FrameworkObject
    • SerializedObject

Constructors

Methods

  • Deserializes data stored in this object.

    Type Parameters

    • T

    Parameters

    • type: Type

      The type to cast the object to after deserialization. If the type does not match, null is returned.

    Returns T

    Deserialized object if successful, null otherwise.

    Component types and TypeScriptResource types cannot be deserialized.

  • Evaluates path on the serialized object and returns the value, if there is any.

    Type Parameters

    • T

    Parameters

    • path: string

      The path to be evaluated on the serialized object.

    Returns T

    The value at the evaluated path.

    The path evaluator currently only supports evaluating objects. Path elements are separated by a "." character, similar to how one would address objects in JavaScript.

    For instance, assuming the object contains a "position" object that is of type Vector3, the path to the X component of position would be "position._x". Note that internal names are used, so some knowledge of the internals of the serialized object is required. A general rule is to avoid evaluating the path on types you don't own, since the internal details of it could change at any time.

    Descending into arrays and maps is not supported at the moment, but values that are arrays or maps can still be returned from the path evaluation.

  • Evaluates path on the serialized object and sets it to a new value.

    Type Parameters

    • T

    Parameters

    • path: string

      The path to be evaluated on the serialized object.

    • value: T

      The value to be set on the evaluated object.

    Returns boolean

    True if the path is valid and the value was set.

    This will not create any preceding path, so all paths elements up to the last must be valid prior to calling this call.

    getValueWithPath - For information about the path syntax.

  • Serializes all data within the provided object.

    Parameters

    • object: any

      Object to serialize.

    Returns SerializedObject

    Object containing serialized data.