Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


CopySerializedManagedFieldsOnly(object, object)

Copies the serializable fields from one managed object to another.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor

CopySerializedManagedFieldsOnly(Object, Object)

public static void CopySerializedManagedFieldsOnly(object source, object dest)

Parameters

source

The object to copy data from.

dest

The object to copy data to.

Remarks

This is similar to EditorUtility.CopySerialized, but you can use it with any two managed objects, rather than two instances of the same Object subclass.
CopySerializedManagedFieldsOnly
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.
CopySerializedManagedFieldsOnly
only copies fields defined in managed code. This means that if you attempt to copy engine objects such as Transform or Light,
CopySerializedManagedFieldsOnly
does not copy any data, since all of their serializable fields are defined in native code.