- Home /
yield www problems in javascript
I'm having almost the exact same problem as this other post http://answers.unity3d.com/questions/38753/yield-return-www-not-returning, except I'm using Javascript. In a nutshell I'm doing this (the url is way simplified for this example):
function PostScore(score:int) { var www:WWW = new WWW(myScoreURL + "?value=" + score);
yield www;
}
Nothing happens.
However, if I replace yield www with this, it works in debug mode, but outright crashes web browsers.
while (www.isDone == false)
{
// Wait
}
If I throw a yield in the middle of the while loop, then nothing happens again.
Answer by Mike 3 · Mar 24, 2011 at 05:22 AM
I'd try the same thing I suggested in the other post - use StartCoroutine(PostScore(score));
Javascript can go a bit wonky with implicit coroutine calling, especially if the function is in a non monobehaviour class
Yes, this works. I didn't do it originally because the documentation says that it's not necessary in Javascript since it does it automatically. Hmm. Thanks!
Your answer
Follow this Question
Related Questions
WWW/ yield calls throwing errors on iPad 1 Answer
WWW execution (working in browser) 2 Answers
Calling function in another script dying without error 0 Answers
Issues with WWW resource loading 1 Answer
How to yiled a try/catch block? 2 Answers