- Home /
yield return www probem
Need help with the c# code. problem is in yield return www. everything works great in unity editor and standalone exe file, but on android and webplayer it doesn't work. This code gets some json information from localhost and with "for" loop assigns json values to some variables. first yield return request; works great, but there is a problem on second yield return www;. In first yield i get names and scores and on second yield i get picture links. The links look like "graph.facebook.com/v2.1/816783911674988/picture/". If i change the code N[i]["picture"].Value to something like this "http://www.something.com/images/somthing.jpg" everything works fine. i don't understand what i am doing wrong.
IEnumerator GetData()
{
WWW request = new WWW("http://localhost/disp.php");
yield return request;
if (request.error == null || request.error == "")
{
var N = JSON.Parse(request.text);
for (int i = 0; i <=9; i++)
{
if(N[i] != null)
{
Fname.text = N[i]["name"].Value;
Fscore.text = N[i]["score"].Value;
WWW www = new WWW(N[i]["picture"].Value);
yield return www;
fpicture.mainTexture = www.texture;
GameObject itemleft = NGUITools.AddChild(friendslistgrid,itemprefab);
}
friendslistgrid.GetComponent<UIGrid>().Reposition();
}
}
please halp.
what does http://localhost/disp.php
evaluate to on android/web?