Prefab referencing so many dependencies??

This prefab is a simple coin pile that drops from enemies, but, when I look at the event viewer, the dependencies for the prefab are completely wrong.

Half of those dependencies have absolutely no relation with the coin pile.

The bundles are packed together by label though, so does this mean that the entire prefabs bundle for the group and all it’s dependencies are loaded into memory just for one prefab?

Does the prefab coin reference other prefabs? I’d have to see the inspector on that particular prefab

Nop it’s just some scripts without prefabs, and an animator.

The problem goes away when I build the bundle with all prefabs separately though.

That’s not how bundles work right?

If you have an entire bundles with all your textures for example and a prefab uses 1 of those textures, the entire bundle and all its dependencies isn’t loaded in right?

If the bundle is set to pack together then I believe they will all share the dependencies since Unity will bundle them together.

Blegh more issues to work around.

If that’s the case then I don’t see how one could make big bundles.
Then you’d have to practically make every single asset a single bundle except for maybe a model with a unique material and textures that aren’t used anywhere else.

I use alot of shared materials for example in my project so I’d have to make every material a separate bundle so all the other materials wouldnt be loaded.

Can’t you just set the bundle to Pack Separately?

That’s probably what I’m gonna have to do ye, but I wanted to avoid having hundreds of bundles.
I feel like that’s gonna be a nightmare to update the bundles on a remote server.

Also I still want to know how this actually works, cause the docs actually comment on this.
When the compression is LZ4 the bundles don’t need to be completely loaded and it can just read in chunks or something.

If only a unity dev could give some info on this.

Yeah sorry I can’t be as much help as a Unity dev. I just kind of deal with that dependency thing with my remote bundles, and honestly I haven’t had any problems with performance on mobile during my testing.

Howdy! I’ll kick this over to the team, and share any insight they have!

We had similar issues with dependency management in our current production project. I’ve tried different strategies for setting up the bundles but in the end it all turned out to be too much manual work so we’ve started to use GitHub - favoyang/unity-addressable-importer: A rule based addressable asset importer to automatically setup bundles for each of our “atomic” assets (like “objects” with all their direct dependencies). This greatly improved our iteration speed (no more setup of bundles for new objects!) and also greatly reduced our build sizes due to vastly better laid out bundles with less duplication and minimal dependencies. (We now have like 10GB of data in ~600 bundles that builds in ~2.5h and we may look into strategies to merge bundles into larger files for less I/O overhead)

@lejean_1 yeah I think your pack by labels is what’s messing you up. Because your coins are packed in with all your other prefabs, we have to include all dependencies in your prefab bundle. And if any of those dependent bundles have other dependencies those will also have to be loaded.

Just a suggestion, I probably wouldn’t use the pack by label feature to pack all the same types of assets. I’d try and group them based on things I knew would likely need to be loaded at the same time. “level 1” or “treasure room” labels for everything you’d need for a given scene.

2 Likes

Thx but then what do I do with stuff like shared materials/animations/textures that could be used anywhere?

Move them into a separate bundle. The SBP will detect the dependencies and reference the “shared bundle” wherever an asset from within it is used. Addressables will then take care of loading those in the correct order, refcounting, unloading etc.
What you shouldn’t do is, use assets in a build (e.g. a model that is in a scene that is included in the build settings) as well as in bundles. That will with no doubt create duplicates as you need to have it in your build as well as the bundle. You’d need to opt-in to a “full addressables” build in that case, where all your assets, scenes etc. are put into bundles.

@lejean_1 I agree with @einWikinger , shared assets should be moved into their own bundle. If you use the Analyze tool there’s a rule you can run to check for duplicate assets in multiple groups/bundles. Whatever it detects you can “fix” and it’ll move all those assets into a single monolithic group (which you can then edit and change as needed). You want to avoid having shared assets built into every single AssetBundle that uses them if you can. That’ll cause a lot of bloat in your builds.