Unity Addressables CDN: Leveraging BunnyCDN BunnyCDN is a special CDN. It will always have a special place in my heart. BunnyCDN not only distributes your content over the networks that are the closest to your players. It also gives you the power to store your data directly within their servers. You eliminate the complexity of hosting somewhere and serving somewhere else. And prices are damn juicy compared to the giants. As the time of writing, storage starts at $0.01/GB per month and distribution at $0.005/GB transferred. And they give you a very generous 14-day trial with 1TB of transfer. I'll keep the instructions shorter than the story. I promise to try.

1. Creating Bunny CDN Account Sign up for the free trial. Fill in the details and such, you know how that all goes. I mean, you also sign up here with your e-mail sometimes. Once you're all set, we will create something known as storage zone. 2. Creating a CDN Storage Zone Here we will create an area where to upload files to. Think of this as FTP server or a Dropbox account (no, I'm not affiliated with Dropbox either). Navigate over to storage zones and add a new one. Choose a name just for you. Don't overthink it, no one else other than you will see it.

That's it. Now you've got a storage zone just for you. Here we will upload our asset bundles. For that, we can either count on FTP or API access. For API automation check the last section of the post. Here's how you do this with FTP. If you go to your storage zone, you'll see a FTP section on the left menu. Clicking there will give you access to your hostname, username and password. Save these details in software like FileZilla.

3. Creating a CDN Pull Zone For Unity Addressables Now that we have a storage space, we will create what is known as a pull zone. A pull zone plays the distribution role of the equation. It takes whatever data you have in the storage zone and offers it to the world.

You're still in the storage zone you just created, right? On the top-right corner, click on Connect Pull Zone.

Now comes the interesting part: the pull zone settings. Give it a name. This time, give your best one. This field will form part of the final URL. You want it to look pretty. When it comes to performance/price, you have two options. You can select the Standard Tier, which is more expensive but includes a lot of nodes around the world. This option is great if you absolutely want to minimize latency. And you want to do that for your website like I do, for instance. My recommendation for you? Save some money and go for the High Volume Tier instead. You'll benefit more from an extra coffee per month than by saving your clients 20ms in downloading asset bundles. This tier will costs you half.

Once you created it, look for the HTTP URL to access your content. You can find it in the pull area you just created. It follows the following structure: http://your-pullzone-name.b-cdn.net

(e.g. http://crappycrush.b-cdn.net) Okay, copy that URL into your clipboard. We will need it now. 4. Configuring Unity Addressable Profiles Unity uses the concepts of Profiles to set the "environment variables" for the Addressables system. RemoteLoadPath is the important variable. This field tells Unity the base URL to use to look for the remote assets we will build. Open your profiles by clicking on Window Asset Management Addressables Profiles. Then, select your current profile (or create a new profile called Production). Change the RemoteLoadPath to reflect your custom CDN URL and keep the [BuildTarget] suffix. Since asset bundles are platform-dependent, Unity will replace the BuildTarget platform on run-time. Here's an example: http://crappycrush.b-cdn.net/[BuildTarget] Now Unity knows where to find our remote assets. The next step is to configure which assets should be built for remote distribution.

5. Configuring Unity Addressable Groups I assume you have some Addressables-based content. In my case, it is a scene called LeaderboardUI. This scene is within the Leaderboard group. Note that, making a scene Addressable will automatically resolve the scene's asset dependencies for you. The final asset bundles will contain all the content the scene requires. Navigate to the Addressables Groups window. Find it under Window → Asset Management → Addressables → Groups. Then, select the group you want to distribute remotely. By selecting the group, the inspector will show you its settings. There, you'll want to change the build path from LocalBuildPath to RemoteBuildPath. Change as well the load path from LocalLoadPath to RemoteLoadPath. This will make sure Unity knows we are marking this asset bundle for remote distribution. To test your CDN I suggest you to temporarily turn off the asset bundle caching system.

Back to the Addressables Groups, make sure the current profile is set to the profile we just modified. Now we just need to build the remote asset bundles. We do this by pressing Build → New build → Default Build Script. You'll find the generated bundles under YourUnityProject/ServerData. 6. Uploading Addressables Asset Bundles to CDN If you navigate to the ServerData directory, you'll find a subfolder named after the active build target. As I am targeting windows, I have a subdirectory called Standalone64. Inside that directory you'll see all asset bundles built for that specific target. But in any case, you'll want to upload the contents of the ServerData directory. You can do this with the FTP connection to your storage zone.

7. Testing Your Remote Addressables Content This is the easiest step. Do you know why? Because if you already had Addressables in place, there's no change required in your code. Your new clients will now fetch your bundle from the server automatically.