October 14 2019

Unity Addressables Hosting: Amazon S3 in 4 Steps


Players want to play, they don’t want to wait. Help them buying your game: reduce your game’s download size with Unity Addressables Hosting. And a year later? Offer them a DLC based on, guess what? Unity Addressables.

Picture your potential player on a Friday afternoon.

Your player has just left behind a hard week with long working hours. Their wife or husband is gone to their family’s country house for the weekend along with the kids. The perfect time to go home, order pizza and browse through Steam with the wallet at hand.

With or without kids, with or without partner, we all had these awesome weekends.

Just videogames, please.

So your player comes across your newly released game in the Steam shop. They see all the effort you put into creating polished content.

No need for convincing, they hand in their credit card details and buy two copies of your game. One for theirself, another for their friend / brother / sister.

You get your 19.95 bucks, twice. Both users happily start installing the game.

But wait…

A wild Steam installation pop-up appears.

The remaining installation time suddenly exploded to 12 hours

What, 12 hours for over 30GB? What the fuck is in this game?**I’m not wasting my weekend on this shit, I’m out!

What happens afterward is not uncommon.

Your ex-player requests a full refund and purchase instead the next game in their wish-list.

One of the pain points for players is the waiting time wasted on downloading all the bytes of the whole game and start playing. People do not have that much time. Nothing will burn a hole in your wallet faster than an angry player.

Do you need to include in your installation package all these assets that are spawned in the level 5 of your game? Chances are, you don’t.

Players will need a couple of hours to play through the initial content of your game. Use that to your advantage

The idea is simple.

Provide the minimum content possible in your game installation package and download the rest while playing the initial levels of your game.

Can you picture your player ready to play in a mere minute after purchasing your game? How different would the reviews be compared to the ones commonly found with huge games?

Ideally, your game’s download size should be below 100MB.

But how?

This is what you will get by the time you’re done implementing the information of this article:

  • Ridiculously **tiny installation sizes**
  • A new **Amazon S3 bucket** to host your content online
  • Upload Unity Addressable Assets to S3 through the Unity Editor
  • Download the Unity Addressable Assets from the S3 bucket in your player builds
  • A high-five from your happy players
Fox / Via mashable.com

Level 1 Developer: “Storage is cheap, anyway”

We started developing our game a few months ago and we have big plans for it.

You and I worked endless hours into creating highly polished content.

Not only that, we saw some great offers in the Unity Asset Store, so we bought several asset packs at heavily discounted prices.

Now our game is full of content our players will love to play through. Those Sci-Fi modular parts, the exploding particle systems, the punchy soundtrack.

It’s all gorgeous.

And heavy.

And slow to download.

Now your Android APK is well over 2GB, so you need to start messing with expansion files, which adds another good week to your efforts. But it’s fine, we all have time here.

Or maybe you’re publishing on Steam, so you can be at 30 GB, no problem. You just need a few hours for uploading it. And players? It’s ok, people have a fast connection nowadays.

So we released our game. Some players reported some bugs, so we make a 5-minute fix and we go through all the long process again. Build, wait for hours, upload to stores, wait for hours.

And our players? They just re-download the whole thing again. Wait for hours, then start playing.

It’s not a big deal.

Only that you are not recovering all the time you wasted on this previously. And a great deal of your players will stop downloading your game once they see how many hours they have to wait. That only gets worse with each update. Did I mention refunds?

We can do better than this, now that we have the tools.

Let’s upgrade our skills to Level 2.

Level 2 Developer: Unity Addressables Hosting

Welcome to Unity Addressables.

This package will allow you to efficiently manage your game assets. That, my friend, includes online distribution. For an introduction on this topic, visit my previous article on Unity Addressables Benefits for your game.

These are the steps you and I will be following in the article:

  1. Set up an Amazon S3 Bucket for online distribution
  2. Mark our content as Unity Addressable Assets for online distribution
  3. Upload our content to the cloud
  4. Profit from tiny installation sizes (and others)

Like granny said, a 2D sprite is worth a thousand times:

Unity Addressables Hosting with Amazon S3 – Steps

Let’s start with…

1. Setting Up a Free Amazon S3 Bucket

It’s our lucky day. Amazon offers a free tier for their S3 service.

That means, we’re going to host our content for free. The limitations for their free tier is mostly storage space and the number data transfers. At the moment of writing this, you can store for free up 5GB and perform 20,000 GET and 2,000 PUT requests, but do double check it in the official site of AWS Free Tiers.

What we are going to do here is to create an account for AWS so we are ready to upload our game content for further distribution.

You and I will do this as fast as possible. No need to waste time in detail. No BS.Setting up Amazon S3 Hosting for Unity Addressables

  1. Create AWS account

Navigate to the AWS Management Console and click on Create a Free Account.

Enter your e-mail and bla bla bla. That will take you roughly a minute.

Be aware that you’ll need to give them your credit card info to verify your identity.

  1. Choose AWS Plan

Unless you’re going pro right from the start, we want to evaluate this in our game first.

So, after confirming your account, choose the basic plan.

After a few minutes, your account will be activated (you’ll get an e-mail). Then, sign in to your new console and open the S3 service panel:

You are now located at the S3 control panel.

Now we are ready to create the bucket like shown below (change your bucket name and region!):

Leave the permissions set to public for now, you’ll have the chance to tweak them in the future.

Your S3 bucket for Unity Addressables is now ready, congratulations!

That was the most tedious step.

The next step is a piece of cake: time to get your Unity Project to produce downloadable assets.

Summary

  • Use the AWS Management Console to create a Free Tier S3 Bucket
  • For starting, assign public permissions to your S3 Bucket
  • Alternatively, use another storage service based on the spreadsheet in the Resource pack

2. Unity Addressable Assets for Distribution

Finally we made it to Unity. That whole S3 process was getting old.

I will assume you have some content marked as Addressable in your game. If that’s not the case because you are new to this, don’t worry, I have you covered with the previous Unity Addressables Tutorial I wrote.

I’ll show you the steps to get content uploaded in your newly created AWS S3 Bucket. We will do so based on a project I created for this purpose.

Instead of following the whole story, you can also skip the line, get access to de code now and read later.

Unity Addressables – Profile Settings

A. Addressables Profile Configuration

The way to start is to tell Unity where to load remote assets from.

That we achieve by tweaking our Addressables Profile Configuration. In the Addressables main window, click on:

Profile: Default → Inspect Profile Settings.

This will redirect you to the settings we need to tweak.

Here is a collection of funny toys you can play with, but for our purposes we just need to focus on the Profiles section.

We want to make sure we set the Addressables RemoteLoadPath field to the correct URL.

We form the RemoteLoadPath URL by concatenating our S3 Bucket URL with the Unity variable [BuildTarget], like below:

https://YOUR-BUCKET-NAME.s3.YOUR-REGION-NAME.amazonaws.com/[BuildTarget]

E.g. https://thegamedevguru.s3.eu-central-1.amazonaws.com/[BuildTarget]

The [BuildTarget] variable is left on purpose so Unity fetches in run-time the right assets for each of the platforms we build for. Android assets will be packed differently from Standalone, so each of these platforms will require a different directory.

The way I found my S3 Bucket URL is by uploading a random file; if you then navigate to its details, you’ll see the base URL of your file and hence your bucket.

B. Addressable Asset Groups Configuration

So, we just told Unity where to load the remote assets from through the RemoteLoadPath variable.

Great. What is left is to tell which assets should be loaded remotely. Easy.

  1. Go over the heavy assets you want to be downloaded remotely and mark these Assets as Addressable. In our case, it’s the skybox materials.
  2. Open the Unity Addressables Window and assign these assets to Addressable Asset Groups. If you are just starting with Addressables, assign them to a single group for now; e.g. Skyboxes. Eventually, you’ll want them to be grouped in a way that makes sense (check my Level-3 guide on Unity Addressables Tutorial for more info).
  3. Navigate to the Addressables Group inspector settings by clicking on the group and make the following adjustments:
  4. BuildPath is set to RemoteBuildPath
  5. LoadPath is set to RemoteLoadPath

You can see a graphical breakdown of this entire process below.

Asset Groups for Unity Addressables Hosting
![Asset Groups for Unity Addressables Hosting](../../uploads/2019/10/Unity-Addressables-Hosting-Asset-Groups.jpg "Unity-Addressables-Hosting-Asset-Groups")

Asset Groups for Unity Addressables Hosting

Unity Addressable Asset Group Settings for Network Delivery

We now have our skybox content assigned to a group that will be downloaded by your players in run-time.

Summary

  • Set RemoteLoadPath to the base URL of your web hosting provider
  • Append the [BuildTarget] variable into RemoteLoadPath to differentiate multiple platforms
  • Assign your Unity Addressable Assets to a group and tweak its settings to use the remote paths so it’ll be downloaded from your web hosting provider

3. Uploading Content to Amazon S3

All our settings are now in place. What about uploading our content to S3?

This is a simple two-step process:

  1. Build player content.
  2. Upload it to S3.

Building Addressables Player Content is straightforward. Open the Addressables main window and press the button that does just that. This will cook the assets for the current platform your editor is in.

Unity Addressables: Build Player Content

The output content will be stored in the path dictated by the RemoteBuildPath variable you happened to see early in the Unity Addressables Profile Settings. If you didn’t modify it, it’s likely to be in a subfolder of your project called ServerData.

The second step involves navigating to that directory and dropping its contents into the website of your S3 bucket, as you can see just below:

Unity-Addressable Assets – Upload to S3

There you have it, it’s that simple.

However, this can quickly become tedious. It’s a very manual task that could easily be automated. I did just that so now uploading all my assets takes the press of a button inside Unity Editor.

To upload your Unity Addressable Assets directly from the Unity Editor, check my Unity Addressables Hosting Resource Pack at the end of the article.

4. Downloading Assets from Amazon S3

This is the part we all were waiting for. You now have a game you can distribute that is significantly smaller. The remaining part is launching it and watching it download the assets on demand!

If you want to make sure these assets are being effectively downloaded, delete the data from your S3 Bucket, disable the caching option in your Addressable Asset Group Settings, rebuild the content and your player. If you launch it, you should see a few error messages pop up, as you can see below.

Unity Addressable Assets Download Error

If you followed this tutorial on Unity Addressables Hosting, chances are, you will be totally alright

By now, the asset groups you marked to be remotely downloaded are hosted in S3 and Unity knows how to fetch them.

The Gamedev Guru’s S3 Upload Tool

Level 3 Developer: Unity Addressables Hosting Resource Pack

By now you should have your first Unity Addressables Hosting experiment up and running.

You learned how to build player content specifically to target downloadable content.

That’s great, but there’s more than just the basics. To help you further, I prepared a Free Unity Addressables Hosting Resource Pack just for you. This bundle contains:

  • A spreadsheet comparing different hosting alternatives to the pricey S3
  • An extension to upload your Unity Addressable Asset to Amazon S3 directly from the Editor
  • The source code of this project; see it for yourself
  • Newsletter access with exclusive free content

Level up your skills. Download it now.

Download your Level 3
Unity Addressables Hosting
Resource Pack
Yes, I want the free resource pack
Upgrade you game.
Subscribe to our newsletter and get instant access to your Free Resource Packfor Unity Addressables Hosting
Yes, I want the free resource pack
The Gamedev Guru Logo

Performance Labs SL
Paseo de la Castellana 194, Ground Floor B
28046 Madrid, Spain

This website is not sponsored by or affiliated with Facebook, Unity Technologies, Gamedev.net or Gamasutra.

The content you find here is based on my own opinions. Use this information at your own risk.
Some icons provided by Icons8