Apologies if these have been answered before but I am finding it hard to find straightforward answers to these questions.
1. If an asset (e.g texture, material) is marked as Addressable and referenced by a non-addressable does it duplicate the content?
I am trying to minimize the runtime memory usage of our game and am seeing a few duplicates of assets despite them being marked as addressable.
The built in memory profiler shows (detailed, with "Gather Object References’) enabled is showing them referenced by the same objects.
2. If an item is in the Resources folder (e.g a prefab which uses textures/materials from an addressable) will that cause duplication? 3. If I mark a folder as addressable is its content then addressable? The inspector does not show it as addressable
That depends. If the non-addressable is referenced by a built-in scene, or it is in Resources, then yes you will get duplicates.
Yes.
Yes the content should be addressable. You should see it in the addressables groups window. The fact that the inspector doesn’t show it is because you can also individually mark them addressable to assign a custom address (marking folders addressable auto-generates addresses).
Don’t trust the profiler in editor! They will show the same objects referenced because addressables uses the AssetDatabase to load assets in editor by default. You need to make a build and run the profiler against the build to see the true picture.
I am using builds to test against this - PC + iOS. I have also tried the new com.unity.memoryprofiler.
Here is a snapshot of the built-in memory profiler. This sprite sheet is in its own addressable group, referenced by two other addressable groups. The object references point to the same list of objects when inspected.
Seems like from points 1 + 2 I need to refactor some of my work to get some more savings. Thank you very much for that clarity.
Not sure if that’s applicable here but, sprite atlases can get paged, i.e. you get 2 or more pages under the same exact name as Textures. So this could be 2 pages, each with different sprites in it, instead of a duplicated texture…
This atlas is not paged. I have seen paged ones in the profiler and the string on the end is different.
I am working on refactoring how some of my assets are loaded / referenced to see if I can work around this. I am using a few spritesheets the only one not duplicated in the memory profiler is the one used in the boot scene and not any addressable.
Interesting. I was under the impression that paged atlases would have the same Native Object name because it would still be treated as basically the same object just different sprites mapping to different pages…
Then again, I haven’t checked I the native code and don’t know the sprite atlas system enough to actually make a definitive statement on that. Just saying that it could be a thing.
OK just to update on this incase anyone else finds it - all the double sprite altas things were 100% my fault. After my refactoring I have fixed a lot of these issues.
Thanks everyone on this thread + on the addressables team