Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CachedAssetBundle custom path

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

  1. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    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.