Home>

1, Substitute AssetBundle URL in the server into variables
2. Download and cache with UnityWebRequestAssetBundle.GetAssetBundle
3. Make it available on Unity with AssetBundle.getContent
4. When the same scene is loaded, the same AssetBundle will be downloaded because the URL remains the same, and this will lead to an error.

Why can't you?

I studied AssetBundle caching, but I don't know how to use AssetBundleManifest.
There are two manifest files and I don't know how to use them.
Investigating that "AssetBundleCache is assigned to the argument" when caching, but Hash value can not be obtained from Manifest file, Hash value of 000000000000 is put

var webreq = UnityWebRequestAssetBundle.GetAssetBundle (url, cache, 0);
// No value is assigned to variable cache
assetBundleCache = DownloadHandlerAssetBundle.GetContent (webreq);
/ * Reloading Scene already downloads the same file
The AssetBundle '--URL--' can't be loaded because another AssetBundle with the same files is already loaded.
*/
  • Answer # 1

    In short, even if the scene changes, it is only necessary to keep the variable (or each class), so it can be done with either of the following.

    Make static variable

    UseDontDestroyOnLoadso that the GameObject with this script does not disappear when moving the scene, and always use this instance when accessing AssetBundle

  • Answer # 2

    The cache is not relevant.
    Asset bundles can be downloaded from the network or read from a file, butthings with the same name cannot be read at the same time.

    When you have finished using the asset bundle, call AssetBundle.Unload method to discard it, or make it possible to see across scenes as sakura_hara says, or check loaded asset bundles with AssetBundle.GetAllLoadedAssetBundles method Please lend.