Class SerializationUtility

The SerializationUtility class provides utility methods dealing with object serialization and diff generation.

Another way to create serialized object representations is using the SerializedObject.

Constructors

Methods

  • Gets the missing serialization information for the specified object.

    Parameters

    • object: object

    Returns {
        className: string;
        namespace: string;
    }

    The information, or null, if the object does not carry serialization information.

    • className: string
    • namespace: string
  • Acquires the missing type information from source into the target object. This also removes the references from the source object.

    Type Parameters

    • T

    Parameters

    • object: object

      The target object to inject the missing type information to.

    Returns SerializedObject

    target

  • Acquires the missing type information from source object.

    Parameters

    • source: object

      The object to source the missing type information from.

    Returns {
        data: SerializedObject;
        typeName: string;
        typeNamespace: string;
    }

    Type information about the missing type.

  • Clones the specified object. Non-serializable types and fields are ignored in clone. A deep copy is performed on all serializable elements except for resources or game objects.

    Type Parameters

    • T

    Parameters

    • original: T

      Non-null reference to the object to clone. Object type must be serializable.

    Returns T

    Deep copy of the original object.

  • Compares the specified objects using their serialization data. Non-serializable types and fields are ignored in compare. A deep compare is performed on all serializable elements except for resources or game objects.

    Parameters

    • a: any

      A reference to the first object to be compared. Object type must be serializable.

    • b: any

      A reference to the second object to be compared. Object type must be serializable.

    Returns boolean

    True if both objects contain the same data; false otherwise.

  • Compares the specified scene objects using their serialization data. A deep compare is performed on all serializable elements of the scene objects, it's children and components.

    Parameters

    • a: SceneObject

      A reference to the first scene object to be compared.

    • b: SceneObject

      A reference to the second scene object to be compared.

    Returns boolean

    True if both objects contain the same data; false otherwise.

  • Creates an empty instance of the specified type.

    Type Parameters

    • T

      Type of the object to create. Must be serializable.

    Parameters

    Returns T

    New instance of the specified type, or null if the type is not serializable.

  • Deserializes a binary byte array into a concrete TypeScript object.

    Type Parameters

    • T

    Parameters

    • type: ClassOf<T>

      The type of object to be deserialized.

    • data: number[]

      The binary data that represents the object.

    Returns T

    A newly created instance with the contents of data deserialized or null.

  • Determines if the object has it's type information missing.

    Parameters

    • object: object

      The object to test for missing type.

    Returns boolean

    True if the object is an object whose type information was missing at deserialization time.

  • Serializes an object into a binary byte array. This array can be deserialized by giving it to deserializeV1.

    Parameters

    • instance: any

      The object to be serialized into a binary byte array.

    Returns number[]

    A byte array that contains a binary representation of instance.

  • Transfers the missing type information from source into the target object. This also removes the references from the source object.

    After transfer, the source will have its missing data fields removed, and they will be transferred to target.

    Type Parameters

    • T extends object

    Parameters

    • target: T

      The target object to inject the missing type information to.

    • source: object

      The object to source the missing type information from.

    Returns T & Partial<MissingSerializationType>

    target