- Home /
Question by
AasthaK · Jul 03, 2015 at 01:03 PM ·
servercachedownloadingwww.texture
Load image from server
Hi, I am loading image from server using the following code:
WWW www = new WWW(url);
yield return www;
Texture2D texture = null;
if(www.error == null)
{
texture = www.texture;
imageTexture.mainTexture = texture;
}
The problem is that if I pass the same url again, it downloads the same image again.
How can cache the image on device or delete the previous image before downloading the new one.
I also used the code:
var www = WWW.LoadFromCacheOrDownload(url, 5);
yield return www;
if(!string.IsNullOrEmpty(www.error))
{
Debug.Log(www.error);
yield return;
}
var myLoadedAssetBundle = www.assetBundle;
var asset = myLoadedAssetBundle.mainAsset;
but it is not returning any texture and I am getting null reference exception.
Comment
Your answer
Follow this Question
Related Questions
How can I avoid re-importing assets? 3 Answers
How to use cache-server to share imports with other team members? 0 Answers
How I can install Unity Cache Server as Windows Service on 2012 Server R2? 1 Answer
Cache server works only partially 0 Answers
How to fix this error "Cache server is enabled, but endpoint string is not valid " ? 0 Answers