Hi all, I call a function that grabs a texture from my web service using a www object. I yield my www object to wait until its finished. The problem is the rest of my code carries on and so nothing happens with the texture I'm trying to receive.
Here's a code example:
and inside Service Client:
The problem is the material never gets set because it goes ahead and tries to set it before the texture is downloaded. What am I doing wrong?
You have to yield coroutines if you want to wait for them to be finished. Coroutines can only return IEnumerator, not textures or anything else.
You can yield the coroutine, and have it store the texture in a global variable that you access when the coroutine is done (as shown above), or use a delegate that the coroutine runs when it's done.