private void SendRequest(WWW www, ResultCallback callback) { Debug.Log("[LoginService] sendRequest:" + www.url); _coroutineExecuter.Execute(ExecuteRequest(www, callback)); }
public void DownloadOrLoadTexture(string url, string fileName, Action <Texture2D> callback) { if (InCache(fileName)) { if (callback != null) { callback(_cache[fileName]); } return; } if (InDisk(fileName)) { var texture = GetTexture(fileName); _cache.Add(fileName, texture); if (callback != null) { callback(_cache[fileName]); } return; } if (_downloadingQueu.ContainsKey(fileName)) { _downloadingQueu[fileName].Add(callback); return; } _downloadingQueu.Add(fileName, new List <Action <Texture2D> >()); _downloadingQueu[fileName].Add(callback); _coroutineExecuter.Execute(LoadTexture(url, data => { //error loading if (data == null) { LogError("Can'not load image data:" + fileName); ExecuteCallback(fileName, null); return; } var texture = GetTexture(data); if (texture == null) { LogError("Can'not parse image data:" + fileName); ExecuteCallback(fileName, null); return; } if (_cache.ContainsKey(fileName)) { _cache[fileName] = texture; } else { _cache.Add(fileName, texture); } try { DiskStorage.Write(fileName, data); } catch (Exception ex) { Debug.LogException(ex); } ExecuteCallback(fileName, texture); })); }