Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Addressables.CheckForCatalogUpdates always returning Succeeded

Discussion in 'Addressables' started by Lostrick, Oct 28, 2021.

  1. Lostrick

    Lostrick

    Joined:
    Jan 9, 2014
    Posts:
    32
    Hi guys this is my first time using addressables so I might miss something obvious here.
    So I'm trying to check if my local cache assets are up to date by calling
    Addressables.CheckForCatalogUpdates() but it seems like to always return Succeeded even if there's not internet connection. I can't differentiate whether it already checks from the cloud and there's no update with it tried to connect but fail since there's no error at all. I also tried Addressables.GetDownloadSizeAsync but same thing it always return status succeded even without syncing with the cloud asset. Is there anyway to check if my local cache is up to date with the one in the remote server?

    this is my code
    Code (CSharp):
    1. public void CheckForUpdate()
    2.     {
    3.         Addressables.CheckForCatalogUpdates().Completed += (_updates) =>
    4.         {
    5.             if (_updates.Status == AsyncOperationStatus.Failed)
    6.             {
    7.                 Debug.LogWarning("Fetch failed!");
    8.             }
    9.  
    10.             if (_updates.Result.Count > 0)
    11.             {
    12.                 Debug.Log("Available Update:");
    13.                 foreach (var update in _updates.Result)
    14.                 {
    15.                     Debug.Log(update);
    16.                 }
    17.                 // proceed with downloading new content
    18.             }
    19.             else
    20.             {
    21.  
    22.                 Debug.LogError("No Available Update");
    23.                 // proceed with loading from cache
    24.             }
    25.         };
    26.     }
    27.  
    28.     public void Confirmation()
    29.     {
    30.         Addressables.GetDownloadSizeAsync("default").Completed += (x) =>
    31.         {
    32.             print( x.Result.ToString());
    33.             if(x.Result > 0 && x.Status == AsyncOperationStatus.Succeeded)
    34.             {
    35.                 var totalSize = new ByteSize((double)x.Result);
    36.                 confirmationWindow.SetActive(true);
    37.                 confirmationText.text = confirmationText.text.Replace("[size]", totalSize.ToString());
    38.                 print(totalSize.ToString());
    39.  
    40.  
    41.             }
    42.             else downloadCompleteWindow.SetActive(true);
    43.         };
    44.     }
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,438
  3. Lostrick

    Lostrick

    Joined:
    Jan 9, 2014
    Posts:
    32
    Thanks a lot for the reply
    Is there any alternative way to know if my asset is up to date or it's using the local cache? That issue is a few months old and I can't really wait that long.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,438
    I believe a workaround for the "there's no internet connection" issue is to specify a "Catalog download Timeout" greater than 0. You can find this option in the AddressableAssetSettings asset.

    They also fixed some error handling issues in Addressables 1.19.9. If you use an older version, it might be worth to test 1.19.9 or newer.
     
    Last edited: Oct 29, 2021
  5. Lostrick

    Lostrick

    Joined:
    Jan 9, 2014
    Posts:
    32
    Thanks a lot that really help me. Man I was searching this for days and didn't find the fix.

    So in case anyone having this problem, what I did is set the catalog timeout like Peter77 said to 5 and call
    CheckForCatalogUpdates, it will return null result if there's no internet connection. Also a thing to remember is you must initialize the addressable before calling the
    CheckForCatalogUpdates. I'll test it in my real project to see if there's no problem. Thanks again