- Home /
Custom yield return
I would like to implement my own WWW class to make calls to web APIs. Is there anyway I can use yield return with my own class?
Is there some API in Unity that allows me to perform an async operation, BeginA and call yield return and then call EndA to signal to unity to resume?
just a suggestion if you are making a custom class for www, why dont you use Thread Class from .Net ins$$anonymous$$d of StartCoroutine.
What do you mean? I don't understand what you're trying to say.
Threads are what is usually used in program$$anonymous$$g to make parallel and async operations. If you haven't heard of it, it is probably too complex for you to handle at this point. So could you explain more about what custom function are you hoping to achieve? Coroutines (the functions that make use of yield) are much simpler to grasp then classic threading...
lol, I didn't mean I don't know what threads are, but rather why the suggestion of using threads. I wanted to integrate WCF services into my unity app, and making synchronous calls to remote services in the main application loop would be a horrible idea. Since I would rather not get into having to keep track of what thread my code is running on and what they can and can't access (plus being paranoid about using concurrent data structures).
Actually I should close this question since I did some research and figured out how to implement this. Just wrote a behavior that went through a list of async operations in FixedUpdate and checked their IAsyncResult for completion.
Answer by Paulius-Liekis · Apr 09, 2012 at 02:53 PM
You can always have a function (which returns iEnumerator) in your class you you can yield that.
Your answer
Follow this Question
Related Questions
WWW execution (working in browser) 2 Answers
Issues with WWW resource loading 1 Answer
How to yiled a try/catch block? 2 Answers
WWW/ yield calls throwing errors on iPad 1 Answer
yield return on WWW never coming back? 0 Answers