Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by spaceowlpro · Aug 03, 2019 at 10:11 PM · webplayerassetbundlewebrequestassetbundlesdownloadable content

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


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by xxmariofer · Aug 03, 2019 at 11:05 PM

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();
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image spaceowlpro · Aug 04, 2019 at 01:28 AM 0
Share

Thanks! I totally missed that...

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

118 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Access raw AssetBundle data using UnityWebRequest? 4 Answers

UnityWebRequest returns different errors for right urls 0 Answers

[SOLVED] Unity 5: Lightmap dissapearing in web player but not in editor 1 Answer

Asset Bundle with script ? 0 Answers

download asset bundle when app is not active 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges