I’m currently making a test project to test loading assets using addressables and CCD but I’m struggling to get it right
So I started by making 2 scenes one where it loads everything (_MainScene) and the other is present in the asset bundles to load remotely (AssetsScene) that contains some prefabs and images referencing a few atlases. I have a loader script in the main scene that loads the content here it is
public class LoadAddressablesWithCCD : MonoBehaviour
{
//public Image progress;
public bool clearCacheOnStart = false;
public TextMeshProUGUI percentageText;
public TextMeshProUGUI errorText;
public TextMeshProUGUI sizeText;
public Slider downloadSlider;
public Button[] buttons;
public string[] keys;
public UnityEvent<float> ProgressEvent;
public UnityEvent<bool> CompletionEvent;
private AsyncOperationHandle downloadHandle;
// Use this for initialization
IEnumerator Start ()
{
Application.targetFrameRate = 60;
if (clearCacheOnStart)
{
ClearCache();
}
AsyncOperationHandle<List<string>> checkHandle = Addressables.CheckForCatalogUpdates();
Debug.Log(checkHandle.Result);
percentageText.enabled = false;
errorText.enabled = false;
sizeText.enabled = false;
downloadSlider.gameObject.SetActive(false);
/*foreach (var button in buttons)
{
button.enabled = false;
}*/
foreach (var key in keys)
{
AsyncOperationHandle<long> getDownloadSize = Addressables.GetDownloadSizeAsync(key);
yield return getDownloadSize;
if (getDownloadSize.Result > 0)
{
sizeText.enabled = true;
sizeText.text = (getDownloadSize.Result/1024) + " kb";
ClearCache();
}
}
}
public void LoadAdressableBundleByName(string key)
{
StartCoroutine(DownloadAdressableBundleByName(key));
}
public static void LoadScene()
{
Addressables.LoadSceneAsync("AssetsScene", LoadSceneMode.Additive);
}
IEnumerator DownloadAdressableBundleByName(string key)
{
downloadHandle = Addressables.DownloadDependenciesAsync(key, false);
//downloadHandle = Addressables.LoadAssetAsync<GameObject>(key);
float progress = 0;
percentageText.enabled = true;
downloadSlider.gameObject.SetActive(true);
while (downloadHandle.Status == AsyncOperationStatus.None)
{
float percentageComplete = downloadHandle.GetDownloadStatus().Percent;
if (percentageComplete > progress * 1.1) // Report at most every 10% or so
{
progress = percentageComplete; // More accurate %
ProgressEvent.Invoke(progress);
percentageText.enabled = true;
percentageText.text = progress*100 +"%";
downloadSlider.value = progress;
}
yield return null;
}
CompletionEvent.Invoke(downloadHandle.Status == AsyncOperationStatus.Succeeded);
Addressables.Release(downloadHandle); //Release the operation handle
Debug.Log("Loading Done | Key name: " + key);
}
public void ClearCache()
{
foreach (var key in keys)
{
Addressables.ClearDependencyCacheAsync(key);
}
Caching.ClearCache();
}
}
The addressable groups are as follows:
The groups are set to remote and linked with a bucket i call Android. the problems start here. i started by doing both an android build and addressables asset build to upload to my bucket. The apk loads things successfully from my bucket but when i make any edits and rebuild the asset bundles and upload them to my bucket the build seems to try to load an older asset bundle so it gives an error
The error:
it tries to load the file scenes_scenes_all_eda23223d0735ca61191405d4684fa58.bundle
The name of the asset it should load in the bucket:
I’m not actually a programmer so if there is something I’m doing wrong during loading or through the setup of my addressable and CCD I don’t know. any help?