Version: 2022.3

EditorUtility.CopySerializedManagedFieldsOnly

切换到手册
public static void CopySerializedManagedFieldsOnly (object source, object dest);

参数

source 要从中复制数据的对象。
dest 要将数据复制到的对象。

描述

在不同的托管对象之间复制可序列化的字段。

这类似于 CopySerialized,但您可以将它与任何两个托管对象一起使用,但同一个 Object 子类的两个实例除外。

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.

如果源对象实现 ISerializationCallbackReceiver 接口,则在读取任何数据之前调用其 OnBeforeSerialize 方法。同样,如果目标对象实现 ISerializationCallbackReceiver,则在数据已经复制到其字段之后调用其 OnAfterDeserialize 方法。

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.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961