Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Delete specific downloaded asset bundles

Discussion in 'Addressables' started by noxxomatik, Mar 20, 2019.

  1. noxxomatik

    noxxomatik

    Joined:
    May 9, 2018
    Posts:
    8
    Is there a way to delete individual downloaded assets from the device? Caching.ClearCache(); deletes all data in the cache but I would like to offer the user a way to delete individual assets using the label to regain disk space.
     
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    989
    We don't have this yet, but I'm adding it as a feature request, as I like the idea.
     
    noxxomatik and MNNoxMortem like this.
  3. johndis34

    johndis34

    Joined:
    Oct 16, 2012
    Posts:
    4
    We are having an issue with IOS not updating. It functions when we do a build content but when we update the content with addressables it continues to only load previous elements. Same procedure with android functions properly but not with IOS. This seems like that would be a great way to force it to work.
     
  4. noxxomatik

    noxxomatik

    Joined:
    May 9, 2018
    Posts:
    8
    Thanks! That would be great!
     
  5. Anicrofmana

    Anicrofmana

    Joined:
    Sep 10, 2019
    Posts:
    25
    Hello,

    Any news on how to clear a specific asset bundle ?
     
  6. Anicrofmana

    Anicrofmana

    Joined:
    Sep 10, 2019
    Posts:
    25
    Ok so for anyone wondering I tried to fight with the classes a bit, and even if Caching class only lets you delete every asset bundles at once, I achieved deleting only the ones I wanted :

    Code (CSharp):
    1. string path = Caching.GetCacheAt(0).path + "/" + bundleName
    this returns the path of a Directory that represents your assetBundle. In my app, all of the assetsbundles seems to be in the cached folder at index 0.

    Then you just:
    Code (CSharp):
    1. Directory.Delete(path, true)
    It deletes the datas and directory linked to the asset bundle, but there's an error caught because Unity tries to delete a "locked" file (_lock), that actually disappears at the next application start.

    This doesn't seem really rigorous but it's working for now so it can be a temporary solution while we are provided a way to delete asset bundles independently in cache.
     
  7. tomekswk

    tomekswk

    Joined:
    Jun 11, 2015
    Posts:
    19
    Have you tried Caching.ClearAllCachedVersions?
     
  8. Anicrofmana

    Anicrofmana

    Joined:
    Sep 10, 2019
    Posts:
    25
    I did, but I think I can't manage to find the "real" name of the bundle to clear. Everytime I tried it said it succeded but my bundle was still here.
    People who used it seemed to have similar issues, are we doing something wrong ?
     
  9. CanAydin

    CanAydin

    Joined:
    Mar 18, 2013
    Posts:
    10
    Any news on this? Im having similar issued where If i use the Directory.Delete, it will delete it, but when i try to download them again, it cannot find the assetbundle
     
  10. noxxomatik

    noxxomatik

    Joined:
    May 9, 2018
    Posts:
    8
    I coudn't test it fully yet, but the new function Addressables.ClearDependencyCacheAsync("YourAddressablesKey") deletes the cached files of the given key. Just be sure to release all used Assets with Addressables.Release(YourAsset) before.
     
unityunity