private IEnumerator LoadImage(string url, ThumbnailManager.ImageLoadCompleteDelegate onLoadComplete) { WWW wWW = new WWW(url); WWWManager.Add(wWW); yield return(wWW); if (!WWWManager.Remove(wWW)) { yield break; } string error = wWW.error; Texture2D texture = wWW.texture; if (string.IsNullOrEmpty(error)) { this.Store(url, texture); onLoadComplete(texture); this.Remove(url); } else { Service.Get <StaRTSLogger>().ErrorFormat("Error fetching thumbnail at {0}", new object[] { url }); onLoadComplete(null); } wWW.Dispose(); yield break; }
public void GetThumbnail(string guid, ThumbnailSize size, ThumbnailManager.ImageLoadCompleteDelegate onLoadComplete) { size = this.AdjustSize(size); VideoData videoData; if (!Service.Get <VideoDataManager>().VideoDatas.TryGetValue(guid, out videoData)) { Service.Get <StaRTSLogger>().ErrorFormat("Could not find VideoData {0} to load thumbnail", new object[] { guid }); onLoadComplete(null); return; } string thumbnailURL = videoData.GetThumbnailURL(size); Texture2D thumbnail; if (this.thumbnails.TryGetValue(thumbnailURL, out thumbnail)) { onLoadComplete(thumbnail); return; } Service.Get <Engine>().StartCoroutine(this.LoadImage(thumbnailURL, onLoadComplete)); }