In the Start of my scenes I call the method that downloads the assetBundles for that scene. The problem is that it only downloads the first assetBundle from the list, the second does not download it. My code is:

Note: The Debug that shows the url shows the correct url both times, first http://mihost.com/assetbundles/asset1 and then http://mihost.com/assetbundles/asset2. However, in the Debug that shows the assets 'added' in both cases it shows the name only of those in asset1

public virtual IEnumerator LoadBundleFromServer()

var AssetPathOnServer = "http://mihost.com/assetbundles/"   

var assetBundleNames = new List<string>();

    for (int i = 0; i < assetBundleNames.Count; i++)
        var currentAssetBundleName = assetBundleNames[i];
        var url = AssetPathOnServer + currentAssetBundleName;
        Debug.Log("url: " + url);

        var request = UnityWebRequestAssetBundle.GetAssetBundle(url);
        yield return request.SendWebRequest();
        if (!request.isHttpError && !request.isNetworkError)
            var asseBundle = DownloadHandlerAssetBundle.GetContent(request,);

            Debug.Log("count assets: " + AssetNames.Count);

            for (int j = 0; j < AssetNames.Count; j++)
                string assetName = AssetNames[j];
                AssetBundleRequest asset = asseBundle.LoadAssetAsync<AudioClip>(assetName);
                yield return asset;
                AudioClip myClip = asset.asset as AudioClip;
                if (!assetDictionary.ContainsKey(assetName))
                    assetDictionary.Add(assetName, myClip);
                Debug.Log("added: " + assetName);
            //TODO: aqui hay que mostrar un error
            Debug.LogErrorFormat("error request [{0}, {1}]", url, request.error);

public abstract List<string> AssetNames
  • \$\begingroup\$ Where is AssetNames populated? \$\endgroup\$
    – Ed Marty
    Sep 27, 2019 at 13:59
  • \$\begingroup\$ This method is in a parent class, from which all inherit My scenes So AssetNames is an abstract property that each daughter implements, now I realize that the AssetNames property is always returning the assetName of the current scene and that's why they are always the same, instead what I need is somehow to be able to list the assetNames within a bundle. Thank you very much, it was a mistake of my code;) \$\endgroup\$ Sep 27, 2019 at 14:18


You must log in to answer this question.

Browse other questions tagged .