static void DownloadImage(string id, string url) { if (ImageCache.ContainsKey(id) && ImageCache[id] != null) { return; } System.Action <WWW> onDone = (www) => { if (string.IsNullOrEmpty(www.error)) { try { ImageCache[id] = www.texture; } catch (System.Exception e) { Debug.LogException(e); } } else if (ImageCache.ContainsKey(id)) { ImageCache.Remove(id); } window.Repaint(); }; EditorCoroutine.Start(VRCCachedWWW.Get(url, onDone)); }
static void DownloadImage(string id, string url) { if (ImageCache.ContainsKey(id) && ImageCache[id] != null) { return; } System.Action <WWW> onDone = (www) => { if (string.IsNullOrEmpty(www.error)) { try { // converting Texture2D to use linear color space fixes issue with SDK world & avatar thumbnails appearing too dark (also enables mipmaps to improve appearance of thumbnails) Texture2D newTexture2DWithLinearEnabled; newTexture2DWithLinearEnabled = new Texture2D(4, 4, TextureFormat.DXT1, true, true); www.LoadImageIntoTexture(newTexture2DWithLinearEnabled); ImageCache[id] = newTexture2DWithLinearEnabled; } catch (System.Exception e) { Debug.LogException(e); } } else if (ImageCache.ContainsKey(id)) { ImageCache.Remove(id); } }; EditorCoroutine.Start(VRCCachedWWW.Get(url, onDone)); }
static void DownloadImage(string id, string url) { if (string.IsNullOrEmpty(url)) { return; } if (ImageCache.ContainsKey(id) && ImageCache[id] != null) { return; } System.Action <Texture2D> onDone = (texture) => { if (texture != null) { ImageCache[id] = texture; } else if (ImageCache.ContainsKey(id)) { ImageCache.Remove(id); } }; EditorCoroutine.Start(VRCCachedWWW.Get(url, (onDone))); }