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

Caching external content catalog

Discussion in 'Addressables' started by Redtail87, Jan 15, 2020.

  1. Redtail87

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    124
    Hey,

    I have two projects, a main player and a content project.
    I am building bundles in the content project and loading them in the player project by using:
    Code (CSharp):
    1. Addressables.LoadContentCatalogAsync(catalogURL);
    then loading the assets.

    This works fine with a connection to the server, but I would like to implement an offline mode where after the bundles are downloaded the first time, you don't need a connection in the future to load the assets.

    Currently it gives an invalid key exception when offline since the catalog isn't loaded.

    Is it possible to cache the external catalog in the addressables system currently, or will I have to manually download the catalog locally and point the url to it when offline?

    Thanks.
     
    Peter5897 likes this.
  2. ST_ProductVIz

    ST_ProductVIz

    Joined:
    Nov 29, 2017
    Posts:
    27
    +1 - I'd like to implement exactly the same scenario. Is there a built-in way to do it?
     
  3. CharBodman

    CharBodman

    Joined:
    Sep 20, 2018
    Posts:
    36
    You can add a resource locator directly. Though
    Addressables.AddResourceLocator()


    Code (CSharp):
    1.  
    2. // Pseudo code, not actual working code
    3.  
    4. var catalogData = new ContentCatalogData(data)
    5.  
    6. ResourceLocationMap locMap = catalogData.CreateLocator(providerSuffix);
    7.              
    8. addressables.AddResourceLocator(locMap, catalogData.localHash, catalogData.location);


    Code (CSharp):
    1.  
    2. /// <summary>
    3. /// Add a resource locator.
    4. /// </summary>
    5. /// <param name="locator">The locator object.</param>
    6. /// <param name="localCatalogHash">The hash of the local catalog. This can be null if the catalog cannot be updated.</param>
    7. /// <param name="remoteCatalogLocation">The location of the remote catalog. This can be null if the catalog cannot be updated.</param>
    8. public static void AddResourceLocator(IResourceLocator locator, string localCatalogHash = null, IResourceLocation remoteCatalogLocation = null)
    9. {
    10.     m_Addressables.AddResourceLocator(locator, localCatalogHash, remoteCatalogLocation);
    11. }
    12.  
    13.  
     
    Redtail87 likes this.
  4. Redtail87

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    124
    Awesome, Ill try this out, thanks.
     
  5. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    I'm totaly in the same situation.
    But I don't get it to work.

    Can you provide me some more code on how to do it?

    I'm using Version 1.8.3
    Thanks in advance.
     
    ImpossibleRobert and pahe like this.