Duplicate Scriptable Object issue and how to avoid

I’ve started marking my assets as addressables following this video:

And I’m encountering the issue described at the end of the video. Scriptable objects tied to any event systems will get duplicated if I fail or forget to mark them as addressable.

These objects can be really, really hard to track down right now because my project is now reasonably large, and the builds DO NOT FAIL IN PLAY MODE.
I only observe failures after building the project (in this case, for oculus quest).

Is there a way to get this system to fail in playmode so I don’t discover such bugs so late in development (after an android build)?

They say to make all elements addressables to avoid duplicities. But I’m not sure.

I’d propose writing an editor script that gives you a list of object references for all ScriptableObjects not marked as Addressable. There’s some information about how to verify if an asset is addressable here: Is it possible to see if an asset is checked as Addressable in Editor?

You can find all assets of a type using this: Unity - Scripting API: AssetDatabase.FindAssets with the same kind of filter you’d use in the project search box. Probably “t:ScriptableObject” in your case.

I hope this helps! I have a problem with duplicated ScriptableObjects too, but marking those as addressables didn’t solve my issue for some of them.

Hmm ~2 years later, I seem to still be having trouble with my scriptable object channels. It’s very hard to ascertain whether something is getting duplicated, even after marking all scriptable objects as addressable.

You can see exactly what addressables are getting duplicated using the Analyze window: Addressables Analyze | Package Manager UI website

Just marking things as addressable usually isn’t enough. As soon as you directly reference an addressable asset in a non-addressable asset or scene, that reference is going to cause a duplicated asset when building.

This is why I mentioned before, usually you need to go all in on addressables and have all your scenes, content, scriptable objects, everything, organised into addressables groups.

Thinking about how addressables works for a moment, it’s actually quite a bit of overkill to move everything to addressables, because you lose the scene based reference counting semantics for memory management, and basically have to trust yourself to do this quasi-manually.

This can backfire dramatically because maintaining gameobject prefab references that get moved over into addressables groups will break since your moving such prefabs into addressables boxed memory.

I attempted to do this, and ran into far more trouble wasting a lot of time in the process.
For my specific use-case, I simply wanted to avoid duplicating scriptableobjects for my cross-scene event channels. Simply moving ALL of these into an addressables group was sufficient, and keeping everything else un-addressable was also sufficient.

For making DLC and assets that can be downloaded online (where the addressables assets are addressable ALL THE WAY through (including sprites, anmations, textures, EVERYTHING), addressables also have a nice use case, but the vast majority of people should steer clear of addressables if they don’t have a clear use case.

No you don’t. Addressables manages the dependencies as well. You load a scene via addressables, all the dependencies (prefabs in the scene and references to addressable assets, etc) have their count ticked up as necessary. You unload the scene, all these counts are ticked down. Again, this is covered in the memory management page in the docs.

This is the main way I use addressables. Everything is organised into logical addressables groups, and 90% of the time I’m just loading and unloading scenes via addressables. The memory management works fine.

This is no different to asset bundles, as Addressables is just built on top of the old system. Addressables just manages a lot of the low level stuff automatically for you.

I don’t often have to load anything via an addressable asset reference. Usually only if I will only sometimes need the asset loaded. Otherwise, it’s just normal object references, with everything built into addressables. Its not that complicated.

For some reason, a large amount of prefab references broke after I moved them into addressable groups. I currently have no idea why this happened, but moving them out of addressables seemed to fix the issue.

Define ‘broke’? Again, if you have anything non-addressable directly referencing something meant to be addressable, you’ll get duplicated assets on build.

And again, you can use the Analyze window to see exactly what is being duplicated.

I feel like you’re ignoring half of what I’m saying.