Duplicating an object that has been loaded by addressable but moved to DontDestroyOnLoad

Hey!

I’ve been having strange behaviour with this and wanted to know if it’s expected behaviour or a bug.
Basically I have a script that auto builds my credits UI (leaderboards also have the same problem). I have “template” objects with backgrounds and right size font and everything, and make a copy of those for each name that I want in my credits, and move them around etc.

It’s been working great until I recently moved all my UI stuff to addressables (HUDManager with everything under it, like main menu, leaderboards, level select etc) . Now when duplicating those objects, the components on them are “missing script” (and so the code breaks).

I’ve done some further testing and it seems that duplicating any object (even in editor) in the DontDestroyOnLoad “scene” that’s been previously loaded by addressable (from another scene) will result in a broken object with missing scripts. It does “make sense” in a way… but also it doesn’t.

I’ve also confirmed that in the “first” scene that it’s loaded from, I can duplicate objects with no issues even if they are in the DontDestroy scene.

Anyway anyone with a similar problem or a solution ? Right now my plan is to just create enough template objects to fill my credits instead of duplicating them, but that just feels silly.

Unity 2018.4.8f1
Addressables package 1.1.10

1 Like

Still haven’t figured this one out.
For added info, it’s a 100% repro on that. The actual error line is:
UnityException: Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.
But obviously we don’t do that. It also “fails” on the actual INSTANTIATE line, not the next one.

Could you file a ticket against Unity and put the case number here? It sounds like a bug that an instance created by Addressables can’t be copied.

Hey sorry for the delay! Someone from the QA team contacted me for more info and I kinda lost track and never received any update after replying. It seems the bug was never open even though I could reproduce it in a fresh project (and attached the project). Don’t know where to go from here.

On our side we just made the source object an actual prefab asset that we instantiate through addressables (instead of being already in the scene as a template), so we are good, but it might still be a thing.

For those who has stumbled upon this problem, there is a solution in Addressables starting 1.9.2:
https://docs.unity3d.com/Packages/com.unity.addressables@1.9/manual/AddressableAssetsAsyncOperationHandle.html

1 Like