Hello All,
I’m trying to load google image search result (one of the result) into the plane in the game.
Here’s the code:
var query="http://images.google.com/images?q="+_name+"&hl=en&imgsz=Medium";
wwwHtml= new WWW (query);
var returnStr : String;
yield wwwHtml;
returnStr=wwwHtml.data;
var startIndex=returnStr.IndexOf("imgres?imgurl=");
returnStr=returnStr.Substring(startIndex+14);
Debug.Log(returnStr);
var endIndex=returnStr.IndexOf("imgrefurl");
returnStr=returnStr.Substring(0,endIndex-1);
Debug.Log(returnStr);
yield LoadFoodImage(returnStr);
This works “most of times” but it sometimes fails due to the fact that although wwwHtml.isDone becomes true and yield statement ends, wwwHtml.data doesn’t have anything within it. This happens for particular words; for example I can query “food” without any issue, but “bush” only returns empty string.
What am I doing wrong?
btw, I also found out that result image in gif format is not correctly loaded this case(using www.texture). rather it only shows big red question mark. Is there way around this issue?