Sponsored By

Who's Hiding In Your Asset Bundles?

Did you know Unity can silently duplicate your assets in your bundles? Avoid this and wasting more money in CDNs with the Unity Asset Bundle Browser.

Ruben Torres Bonet, Blogger

May 4, 2020

5 Min Read
Game Developer logo in a gray background | Game Developer

[Check the original post at Who's Hiding In Your Unity Asset Bundles?]

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 RAMmore 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

Quick Navigation (redirects to new tab)

Why Would Unity Addressables Deceive You?

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

How to Fix Unity Asset Bundle Asset Duplication

What's Next?

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 timesstorage 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

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like