Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 GrannySmith · Jul 19, 2013 at 12:31 PM · wwwvuforiayielddownloadreturn

Why does nothing happen after yield return www

Ok first: I've seen quite similar questions about this and I've read through articles which explain the whole coroutine and yield structure. Unfortunately I still don't understand why this following code is not working. Basically I am downloading two files (a XML and a binary DAT file) and writing them to the disk afterwards. If you are interested in what the purpose of all of this is: I am making an Augmented Reality App with the Vuforia Framework and I need to download DataSets (which are needed for the image tracking).

     private void LoadAndActivateDataSet ()
     {
         StartCoroutine (DownloadAndSave (baseURL, dataSet + ".xml"));
         StartCoroutine (DownloadAndSave (baseURL, dataSet + ".dat"));
         string myDataPath = Application.persistentDataPath + "/" + dataSet + ".xml";
         LoadDataSet (myDataPath, DataSet.StorageType.STORAGE_ABSOLUTE);
     }
     
     IEnumerator DownloadAndSave (string url, string filename)
     {
         string remoteFile = url + filename;
         string localFile = Application.persistentDataPath + "/" + filename;
 
         Debug.Log ("remoteFile: " + remoteFile);
         Debug.Log ("localFile: " + localFile);
         
         // If the dataset already exists there will be no download
         if (System.IO.File.Exists (localFile)) {
             Debug.Log ("Exists: " + localFile);
             Debug.Log ("No Download Required");
             return true;
         }
         WWW www = new WWW (remoteFile);
         yield return www;
         
         System.IO.File.WriteAllBytes (localFile, www.bytes);
         if (filename.EndsWith (".xml"))
             Debug.Log (www.text);
     }

And with the press of some GUI Button I just execute the method LoadAndActivateDataSet(). The code after yield return www; is not being executed, therefore the downloaded files won't be stored. I've done this the exact same with downloading an AssetBundle, which works very well and it is the exact same code.

So has anyone a clue what could be the problem? Am I misunderstanding the whole thing completely and I have some major error in there?

Comment
Add comment · Show 4
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 SubatomicHero · Jul 19, 2013 at 02:31 PM 2
Share

have you tried using www.progress to capture the download progress in a local float which you can debug? Then you can spot if the file is co$$anonymous$$g down

avatar image GrannySmith · Jul 22, 2013 at 06:50 AM 0
Share

I wouldn't know where to set Progress, because right after WWW www = new WWW(remotefile); it would make no sense, as it will be always 0. And the code after yield return www; is never being executed.

avatar image Benproductions1 · Jul 22, 2013 at 07:40 AM 1
Share

you could have www a public variable and then just update another variable with www's progress every Update. Then you can see if at least something is happening :)

avatar image GrannySmith · Jul 22, 2013 at 08:03 AM 0
Share

I was able to get it running now, but i think the code is completely horrific. I stopped doing Coroutines and i wait for download to finnish with the not so cool while(!www.isdone) endless loop till its downloaded. It works that way, but i think that's is not the proper way to do it and i seem to still not know how proper Coroutines are handled. Which was my initial intention of this question.

0 Replies

· Add your reply
  • Sort: 

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

18 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

Related Questions

WWW/ yield calls throwing errors on iPad 1 Answer

C# Yield in a Method with Return a value 1 Answer

Wait for file download 1 Answer

Downloading big files on iOS ... WWW will give "out of memory" error. 3 Answers

What's the matter downloading with 3G 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