In my code I have several snippets like the one below with different purpose. In the start() method I added the following code "AssetBundle.UnloadAllAssetBundles(false);". When I run the application sometimes it runs without error and sometimes it runs with the following error "can't be loaded because another AssetBundle with the same files is already loaded.".
using (UnityWebRequest webRequest = UnityWebRequestAssetBundle.GetAssetBundle(url))
{
yield return webRequest.SendWebRequest();
if (webRequest.result != UnityWebRequest.Result.Success)
{
Debug.Log(webRequest.error);
}
else
{
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(webRequest);
GameManager.Instance.bundleListCues = new List<Sprite>(bundle.LoadAllAssets<Sprite>());
if (bundle == null)
{
Debug.LogError("Failed to download AssetBundle!");
yield break;
}
bundle.Unload(false);
}
}