Application size reduction with CCD

To entice players to download your game, a good practice is to keep the initial size of your application small, then have the players download files for new levels and assets as needed later.

This section uses an example project to take you through the process of reducing the size of your application by using CCD and Addressables together.

Reduce application size summary

Below is a summary of the application reduction process. Each step is expanded upon later in the document.

  1. Install Addressables and CCD Management packages.
  2. Configure a bucket in CCD.
  3. Create a new scene for your game, or use an existing level to be sent through CCD.
  4. Configure your assets in Unity Editor.
  5. Set up the script that calls your content through Addressables.
  6. Release new assets to CCD in the Unity Cloud Dashboard.

To complete these steps, you need the following:

  • Unity Editor 2019.4 or above
  • Addressables (latest version; this example uses version 1.19.15)
  • CCD Management (latest version; this example uses version 2.0.1)

Install required packages

First, make sure you have installed the required Addressables and CCD Management packages.

  1. In the Unity Editor, select Window > Package Manager.
  2. Search for Addressables, select the version 1.19.15+, then Install.
  3. Search for CCD Management, select the version 2.0.1+, then Install.

Configure a bucket in CCD

The following steps show you how to create and configure a bucket in the Unity Cloud Dashboard.

  1. Complete the CCD in the Unity Cloud Dashboard instructions to access buckets within CCD.

  2. Complete the Buckets instructions to create a bucket.

    1. Make sure to set the Bucket write conditions to Open to all.
    2. When choosing the Environment, set it to production.
  3. Select Create to create the bucket.

  4. Select the bucket from your list of buckets.

  5. Select Upload Content, and upload any file from your computer.

    This step is only to create and retrieve a URL for your bucket. You can delete this file once you create your initial release.

  6. Refresh the page then create a release.

  7. Select the release from the Releases tab.

  8. Select the Addressable Remote Path URLs tab.

  9. Copy the Badge: Latest URL for use later in the Unity Editor.

Configure the Unity Editor

Continue the app size reduction process by setting the following in the Unity Editor.

  1. Go to Window > Asset Management > Addressables > Groups.
  2. If you have not used Addressable Assets before, you must select Create Addressables Settings.
  3. Select Profile > Manage Profiles in the Addressables Groups window.
  4. Select the Default profile.
  5. Set Remote to Custom.
  6. Expand the Remote field, and set Remote.LoadPath to the URL you saved earlier.
  7. From the Unity Editor main window, select Window > Asset Management > Addressables > Settings.
  8. Enable Build Remote Catalog.
  9. Set Build & Load Paths to Remote.

Prepare the scenes

Next, prepare the scene or scenes to load through CCD. Make sure you have at least one scene that is different from the initial level.

Scene creation is outside the scope of this use case. See the Unity Manual: Scenes documentation for more information.

  1. In the Unity Editor, find your scene among your assets in the Project tab.

  2. In the Inspector tab, enable Addressable.

    Alternatively, drag the scene from the Project tab into the Addressables Groups tab’s Default Local Group.

  3. Within the Addressables Groups tab, right-click on the asset and select Simplify Addressable Names for easier readability.

  4. Select the Default Local Group.

  5. In the Inspector:

    1. Set Build & Load Paths to <custom>.
    2. Set Build Path to RemoteBuildPath.
    3. Set Load Path to RemoteLoadPath.
  6. Back in the Addressables Groups window, select Build > New Build > Default Build Script.

    If you have previously already run a build, you can update it by selecting Build > Update a Previous Build, then selecting the build’s .bin file.

Compare builds (optional)

In this optional step, compare build size by building the application once with the scene, and once without the scene. In this test application, there is a roughly 30 MB difference. In larger applications with more levels and assets, the size savings would be greater.

The size of the release with the scene and the assets included (left) versus the size of the release without the scene (right).

Configure your script

In the main scene (the scene to be built with the project), make sure to add a button or an event within the game that loads the next level.

Be sure to exclude from your build any scenes that you are sending through CCD to avoid conflicts.

You can attach the following example script to a button in your game. Be sure to fill in the addressable name (sceneName in this example) in the Inspector.

C#

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.AddressableAssets;
 
public class LoadSceneCCD : MonoBehaviour
{
    public string sceneName = "";
 
    public void LoadTargetScene()
    {
        Addressables.LoadSceneAsync(sceneName, UnityEngine.SceneManagement.LoadSceneMode.Single, true);
    }
}

Prepare AssetBundle for Dashboard upload

Prepare your scene assets to upload to the Unity Cloud Dashboard by completing these steps:

  1. In the Unity Editor, select Window > Asset Management > Addressables > Groups.
  2. Select Build > New Build > Default Build Script.
  3. Once the build is complete, on your local drive, go to your project folder, then ServerData\StandaloneWindows64. Note that this folder may vary depending on the platform you are building for.
  4. Take note of the files ending in .hash and .bundle.

Upload to the Dashboard

Upload the recently built .hash and .bundle files that you generated from the previous step. If this is your first upload, select and upload all files.

  1. Return to the buckets page of the CCD section in the Unity Cloud Dashboard.
  2. Select the bucket you created.
  3. Within the Latest tab, under Entries, select the Upload Content tab.
  4. Browse and select the files you build in the previous step.
  5. Select Upload Files.
  6. Select Refresh Page once the upload is complete.
  7. Select Create Release, applying the Latest badge for your new content.

Test your build

You can test your build by clicking on the button or action that triggers loading the CCD scene. If everything went correctly, your CCD scene should load after a small delay. Your build should only contain the main scene and not the level you want to load through CCD, otherwise you haven’t reduced the size of your application.