I have some objects who needs the content of a downloaded file. I have an object who download the file. This object has a method like "GetGoodContent" which is called on "Start" in the first objects. Is it possible to do the following behaviour. And how ?
On first call of "GetGoodContent" start the download and wait for the download is complete and retrieve the good data in the file. My actual problem is that when i call "GetGoodContent" the file is downloaded but the execution continues, and the data can't be filed in my objects. I need to wait the download to be completed.
Thanks a lot !
You really don't want to stop everything to wait for that download. The point of coroutines and 'yield' is to allow the game to continue, and you can process the downloaded data when it's done downloading. In JS you do that after the 'yield', in CS you do that in a coroutine which is called once the data is done downloading. Your game doesn't have to progress (you can not have it do anything real until you get the 'all clear' from your post-yield or coroutine). So if you need it to appear to do nothing, then set a boolean variable like 'downloaded' and have other things not happen if downloaded is false. Set downloaded true once you have processed the downloaded data.
answered Jul 11 '12 at 11:24 PM