Search Unity

CachedAssetBundle custom path

Discussion in 'Asset Bundles' started by squall-leonhart, Aug 18, 2019.

  1. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    20
    I am trying to use CacheAssetBundle to download bundles to a custom cache path.Below codes run successfully however when I check the custom path the bundle does not exist in the custom path. I think I might have misunderstood the documentation.Any help is greatly appreciated

    Code (CSharp):
    1.  
    2. var cacheBundles = new CachedAssetBundle
    3. {
    4.   hash = Versions[bundleName],
    5. // read from PlayerPrefs, the value is from BuildPipeline.GetHashForAssetBundle during assetbundle build
    6.   name = CommonUtils.FilePathToFileUrl(_dynamicAssetBundlePath)
    7. // the method change the file path C:/Users/<username>/AppData/LocalLow/updates/<gamename>\Windows to uri file:///C:/Users/<username>/AppData/LocalLow/updates/<gamename>/Windows
    8. };
    9. wr = UnityWebRequestAssetBundle.GetAssetBundle(url, cacheBundles, CRCs[url]);
    10. // read from PlayerPrefs, the value is fromBuildPipeline.GetCRCForAssetBundle during assetbundle build
    11.  
    12. // .. usual stuffs
    13. yield return wr.SendWebRequest();
    14.  
    15. if (wr.isNetworkError || wr.isHttpError)
    16. {
    17.     error?.Invoke(wr.error);
    18. }
    19. else
    20. ...
    21. ....
    22.