- Home /
Reliable way to download textures
Is there a reliable way to download textures from http server ? At the moment I tend to get questions marks from time to time and it seems to be random. I am using .png format images. Suggestions welcome, thanks.
private IEnumerator setQuestionImage(string urlk,int index){
Texture2D tex = new Texture2D(2, 2,TextureFormat.DXT5Crunched, false);
string url = "http://127.0.0.1/test.php?key="+urlk;
WWW www = new WWW(url);
yield return www;
www.LoadImageIntoTexture(tex);
this.ret = Sprite.Create(tex,new Rect(0, 0, tex.width, tex.height),new Vector2(0.5f, 0.5f));
www.Dispose();
}
Comment
Answer by sumeeton · Jul 31, 2015 at 06:02 PM
Check for errors before loading the texture.
if(www.error != null)
{
Debug.Log(www.error);
}
else
{
// Load texture
}
www.Dispose() should be used to abort downloading process. I don't see any use of the call in your implementatin.
Your answer
Follow this Question
Related Questions
Is System.Net.HttpWebRequest supported on Android/iOS 1 Answer
uploading png with wwwform 0 Answers
WWW.uploadProgress doesn't work on iOS 0 Answers
best way to show iphone purchased assets 0 Answers