Does DuplicateObject() perform a shallow or deep copy?

If a SubObject in a marked UProperty of the Target Object you called DuplicateObject() on, has the Target Object in their Outer Chain (It’s the first parameter when you call NewObject()), then DuplicateObject() will create a deep copy of that SubObject and assign it to the same property of the Duplicated Object.

This is recursive operation and will apply to children of SubObjects (and so forth) that have the target in their outer chain.

However, if a SubObject doesn’t have the Target Object in its Outer Chain, it will only copy the reference (IE: Shallow Copy) and skip traversing that SubObject for more duplicate targets.

The Outer Object is essentially who owns each Object for Serialization purposes, and DuplicateObject() uses this information for making the deep / shallow decision.

5 Likes