How do I have multiple UnityWebRequests in one coroutine?

I have a DLC scenario in my mobile app. It’s one download button that will retrieve 2 asset bundles from HTTP links. I’ve set up an IEnumerator that goes through a UnityWebRequest, gets the asset bundle, stores it, and then disposes itself. The coroutine gets to line 77 where the second UWR should start, and I get this error message:


“InvalidOperationException: Cannot get content from an unfinished UnityWebRequest object”


So, what’s going on here? I check to see if the UWR’s Download Handler is finished and then dispose of both the handler and the UWR itself. So why am I getting an error message saying that there’s an unfinished UWR object? I’m missing something here…

Thanks for the help! Here’s my code:


#elif UNITY_IOS || Unity_Editor
        using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(myaamiakiAssets))
        {
            Debug.Log("Downloading audio assets.");
            yield return uwr.SendWebRequest();

            if (uwr.isNetworkError || uwr.isHttpError)
            {
                Debug.Log(uwr.error);
                downloadButton.SetActive(true);
                downloadingIcon.SetActive(false);
                yield break;
            }
            else
            {
                // Get downloaded asset bundle
                AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
                downloadingIcon.SetActive(true);
                downloadButton.SetActive(false);
                if (uwr.downloadHandler.isDone)
                {
                    Debug.Log("Audio assets downloaded.");
                    bundleStorage.myaamiakiAssets = bundle;
                    uwr.downloadHandler.Dispose();
                    uwr.Dispose();
                }
            }
        }
        using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(myaamiakiScene))
            {
                Debug.Log("Downloading scene asset.");
                if (uwr.isNetworkError || uwr.isHttpError)
                {
                    Debug.Log(uwr.error);
                    downloadButton.SetActive(true);
                    downloadingIcon.SetActive(false);
                    yield break;
                }
                else
                {
                    // Get downloaded asset bundle
                    AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
                    downloadingIcon.SetActive(true);
                    downloadButton.SetActive(false);
                    if (uwr.downloadHandler.isDone)
                    {
                        Debug.Log("Scene asset downloaded.");
                        bundleStorage.myaamiakiScene = bundle;
                        StartCoroutine(MyaamiakiLoadAndStore());
                        downloadingIcon.SetActive(false);
                        startButton.SetActive(true);
                        //save asset locations
                        metaSaver.SaveGame();
                        yield break;
                    }
                }
            }
        
#endif

maybe the error is you are not yielding or checking if the second webrequest has ended before checking if it has errors?

you are missing the yield i imagine thats the error

yield return uwr.SendWebRequest();