# Deep Copy of ScriptableObject

**URL:** https://discussions.unity.com/t/deep-copy-of-scriptableobject/193126
**Category:** Questions & Answers
**Created:** [August 10, 2017, 9:44am UTC](https://discussions.unity.com/t/deep-copy-of-scriptableobject/193126 "2017-08-10T09:44:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dCalle](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@dCalle](https://discussions.unity.com/u/dCalle)
#### Post date: [August 10, 2017, 9:44am UTC](https://discussions.unity.com/t/deep-copy-of-scriptableobject/193126/1 "2017-08-10T09:44:21Z")

</div>

Hey, I know a similar topic is floating around in Answers, but it’s some years old and doesn’t work, at least for me…

So I want to copy a scriptableObject WITH its references…  
CopySerialized doesn’t work as well as Instantiate… does not…

What am I doing wrong?

```
        internal static PersonalObject Personalise(this PersonalObject pObject, Object owner)
        {
            string newPath = CreateAssetDirectory(pObject.GetType(), owner);
            newPath = AssetDatabase.GenerateUniqueAssetPath(newPath + "/" + pObject.GetType().Name + ".asset");

            PersonalObject newObject = ScriptableObject.Instantiate(pObject) as PersonalObject;
            AssetDatabase.CreateAsset(newObject, newPath);
            EditorUtility.CopySerialized(pObject, newObject);
            newObject.isPersonalised = true;
            newObject.ownerID = owner.GetInstanceID();
            return newObject;
        }

```

I shuffled order in any way I could imagine, also used AssetDatabase.CopyAsset, nothing works. Is CopySerialized supposed to use the SerializedObject?

Thanks…

---

<div class="post-metadata">

### Author: ![Bunny83](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@Bunny83](https://discussions.unity.com/u/Bunny83)
#### Post date: [August 13, 2017, 2:09pm UTC](https://discussions.unity.com/t/deep-copy-of-scriptableobject/193126/2 "2017-08-13T14:09:55Z")

</div>

Serialized references will always stay references. The only exception are references to child objects when cloning gameobjects.

ScriptableObjects are assets. Assets can only reference other assets. So if you want a “true” deep copy it would have a quite heavy effect. For example when your scriptable object references other scriptable objects which might reference prefabs. A deep copy would require to also duplicate those “referenced” scriptableobjects as well. However since they are assets they need a new file name. However the referenced prefabs would also need to be duplicated. If the prefabs reference Meshes and materials those need to be duplicated as well. The Material will reference a shader and some textures which would be duplicated as well. I can’t really imagine any situation where you need that.

In most cases you will have only some specific references you want to duplicate. In that case you have to duplicate those manually. Keep in mind that all assets need to be stored in some sort of asset file.

If that doesn’t answer your question you should be more specific about what kind of references you talk about and what you mean by “deep copy”.

---

<div class="post-metadata">

### Author: ![Culzean](https://avatars.discourse-cdn.com/v4/letter/c/e9c0ed/32.png) [@Culzean](https://discussions.unity.com/u/Culzean)
#### Post date: [May 15, 2026, 7:00pm UTC](https://discussions.unity.com/t/deep-copy-of-scriptableobject/193126/3 "2026-05-15T19:00:59Z")

</div>

The problem is that `Instantiate` and `CopySerialized` both do a shallow copy. Any nested ScriptableObject references just carry over pointing to the same original assets — none of the built-in methods walk the hierarchy and duplicate them.

To actually do it properly you need to iterate the serialized properties using `SerializedObject`/`SerializedProperty`, find every nested SO reference, `CreateInstance` a copy of each, save them as new `.asset` files, then re-wire the references back up the chain. This gets very deep into recursive C# reflection calls, especially once you have more than a couple levels of nesting, and is not pretty.

I hit this same problem and ended up just building a tool for it — Deep Clone on the Asset Store handles it with a single button-press: [Deep Clone - ScriptableObjects | Utilities Tools | Unity Asset Store](https://assetstore.unity.com/packages/tools/utilities/deep-clone-scriptableobjects-321866)

If you want to roll your own I’m happy to go into more detail on the recursive approach.
