I think I’m still missing something important about Addressables and would love some insight.
First, what I’m trying to do: to have my large assets as Addressables and loaded initially. Using the Unity CCD, I build and upload almost 200 mbs of data to my bucket, but my final .aab build doesn’t change. If I add my initial scene level, which is like 10mbs, as an Addressable scene then the final build file size jumps down significantly. If I remove that scene as an Addressable, nothing changes.
What I’m building as Addressables: FBX files, 4K textures, sound files, etc. These represent the bulk of what my scenes are comprised of, and makes the most sense to push this off to the Cloud for retrieval later.
Here is my code for the dependencies
AsyncOperationHandle downloadDependencies;
private void OnEnable()
{
// fire off this Unity Event to let the user know that we're updating dependencies
onStartAssetsLoading.Invoke();
downloadDependencies = Addressables.DownloadDependenciesAsync("CloudAsset");
downloadDependencies.Completed += DownloadDependenciesCompleted;
}
private void Update()
{
progressBar.value = downloadDependencies.PercentComplete;
}
private void DownloadDependenciesCompleted(AsyncOperationHandle obj)
{
if (obj.Status == AsyncOperationStatus.Succeeded)
onAssetsDone.Invoke();// fire off event which immediately loads start menu
else
Debug.LogError("Loading Scene Failed");
}
Here is my Addressable Group setup with the CloudAsset label.
And here is the settings for my default group
Is there something else I need to do to get my CloudAssets to not be included in the .aab build?
My 2nd question pertaining to all this, going back to including my scene in the Addressable build; if I include my initial level, I then use this code to handle the Addressable Scene load:
public AssetReference initialScene;
AsyncOperationHandle asyncLevelDependencies;
private void Update()
{
if (progressBar.transform.gameObject.activeInHierarchy)
progressBar.value = asyncLevelDependencies.PercentComplete;
}
// called from the UI level selection button and displays the progress bar
public void LoadTutorialLevel()
{
asyncLevelDependencies = Addressables.DownloadDependenciesAsync(initialScene);
asyncLevelDependencies.Completed += DependenciesComplete;
}
private void DependenciesComplete(AsyncOperationHandle obj)
{
if (obj.Status == AsyncOperationStatus.Succeeded)
Addressables.LoadSceneAsync(initialScene, LoadSceneMode.Single);
else
Debug.LogError("Loading Scene Failed");
}
Again all of this runs fine, except when my level loads everything is Pink in the scene window and the Game window freezes showing the last Canvas screen from the level loading.
Clearly something is not getting downloaded properly, or I’m missing something else.