Version: 2019.1

EditorUtility.CopySerializedManagedFieldsOnly

Switch to Manual
public static void CopySerializedManagedFieldsOnly (object source, object dest);

Parameters

sourceThe object to copy data from.
destThe object to copy data to.

Description

Copies the serializable fields from one managed object to another.

This is similar to CopySerialized, but you can use it with any two managed objects, rather than two instances of the same Object subclass.

CopyScriptManagedFieldsOnly copies all fields supported by the Unity serializer. If the destination object is not of the same class as the source object, then the function matches fields by name, or by using the FormerlySerializedAs attribute. The function does not modify any fields on the destination object which are not serializable, or which do not have corresponding fields in the source object.

If the source object implements the ISerializationCallbackReceiver interface, then its OnBeforeSerialize method is called before any data is read. Similarly, if the destination object implements the ISerializationCallbackReceiver, then its OnAfterDeserialize method is called after data has been copied into its fields.

CopyScriptManagedFieldsOnly only copies fields defined in managed code. This means that if you attempt to copy engine objects such as Transform or Light, CopyScriptManagedFieldsOnly does not copy any data, since all of their serializable fields are defined in native code.