Basic

April 27 2020

0 comments

What’s Hiding In Your Unity Asset Bundles?

By Rubén Torres Bonet

April 27, 2020


__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"6c4de":{"name":"Main Accent","parent":-1},"67ed2":{"name":"Accent Dark","parent":"6c4de","lock":{"saturation":1}}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"6c4de":{"val":"var(--tcb-skin-color-0)"},"67ed2":{"val":"rgb(59, 65, 63)","hsl_parent_dependency":{"h":160,"l":-0.05,"s":0.04}}},"gradients":[]},"original":{"colors":{"6c4de":{"val":"rgb(51, 190, 127)","hsl":{"h":152,"s":0.57,"l":0.47}},"67ed2":{"val":"rgb(59, 65, 63)","hsl_parent_dependency":{"h":160,"s":0.04,"l":0.24}}},"gradients":[]}}]}__CONFIG_colors_palette__

Addressables does it all for you, which makes it easy to trust the system.

But, did you know that Unity can silently duplicate your assets into different bundles?

This means for you: more RAM, more bugs and more money wasted in CDN.

So the question is, do you know what is really hiding in your asset bundles?

And... can you trust Unity?

Let's find out.

In this blog post, I'll show you:

  • Why Addressables can duplicate your addressables content
  • How to explore the contents of your asset bundles
  • How to reduce your asset bundle sizes so you pay less to your greedy CDN and consume less RAM

Why Would Unity Addressables Deceive You?

Unity Addressables is a solid system that does a lot for you, such as resolving asset dependencies automagically for you.

And that's great, but... sometimes it might do just too much.

You see, when you delegate the asset bundle generation to Unity, the system does its best to pack your addressable assets into its groups.

However, a big problem comes with asset inter-dependencies.

How do I know?

Because I suffered from it. And some of my coaching clients did as well.

You won't like this type of surprises, so let me explain how this can affect you.

For simplicity, let's assume your game has 3 types of walls with a different models that share a material.

You put each wall in a different asset bundle, and guess what happens?

Yep, the material and all its textures are duplicated in each asset bundle.

And that's not nice if you have 4k textures.

How do you know the textures are duplicated?

Well, check this out.

Unity Asset Bundle Browser: Contents

Unity Asset Bundle Browser: Contents


Each wall asset bundle contains the same assets except for the mesh.

This issue will skyrocket your asset bundle size, your cooking times and your CDN costs.

You can detect such problems with the Addressable Analyze Rules too. I'll cover that in another post.

So, how do you explore your asset bundle contents like I showed you?

How to Use the Unity Asset Bundle Browsers to Have a Look

First, install the package through the package manager.

Installing Unity Asset Bundle Browser

Installing Unity Asset Bundle Browser

Then, open it through Window → AssetBundle Browser


Once you have the Asset Bundle Browser open, go to the inspect tab and add the asset bundles you generated with the Addressables API.

These bundles are often placed within the addressables' Library folder, e.g. Library \ com.unity.addressables \ StreamingAssetsCopy \ aa \ Windows \ StandaloneWindows64

Unity Addressables: Asset Bundles Location

Unity Addressables: Asset Bundles Location

After you add the Unity asset bundles, you can click on them to inspect its contents.

Within Advanced Data → Preload Table, you'll be able to see which subassets you're including in this bundle.

If you see some of these assets duplicated in different bundles, then you're wasting space.

The good news is that it is easy to fix it.

How to Fix Unity Asset Bundle Asset Duplication

The reason these subassets are duplicated is because they are not marked as addressables.

You see, you can mark these 4k textures as addressable and toss them into their own bundle.

The walls asset bundles would then depend on that single asset bundle containing the textures, instead of duplicating the content.

Here's a diagram that explains the difference.

Unity Addressables: Asset Bundles Content Duplication

Unity Addressables: Asset Bundles Content Duplication

The result?

You'll have smaller bundles, shorter iteration times and you'll pay less to your greedy CDN.

That sounds neat.

Remember, this problem is more relevant if you're unaware of it.

So, spend a bit of your time on checking out if this is an issue in your project.

What's Next?

In short:

  • Unity Addressables makes it simple to group assets into bundles.
  • However, bundles might have duplicated content.
  • Duplicated content increases iteration times, storage requirements and CDN costs.
  • You can inspect your asset bundles' contents with the Unity Asset Bundle Browser.
  • You can fix asset bundle duplication by extracting shared assets into their own bundles.
  • Alternatively, you can use the Addressables Analyze Rules, which can fix the problem for you.

This post is part of the Unity Performance Pillars series that is based on the Unity Performance Checklist.

Get your Unity Performance Checklist now to boost your game performance to avoid nasty 1-star reviews.

Next week I'll show you some modern C# goodness to help you become a high-performing programmer.

~Ruben

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Rubén Torres Bonet

About the author

Born Game Developer, now ready to help you develop better games. Primary programmer on Star Trek Bridge Crew (Oculus Quest), Diamond Dash. Programmer on Time Stall, Catan Universe, Anne Frank House VR, Jelly Splash, Blackguards Definitive Edition. I also worked in minor XR experiences for HoloLens and Vive for clients such as Audi and Volkswagen.

You might also like

>