/// <summary> /// Given a url it will it will make or reuse a cached animated gif component for it in the preview. /// </summary> /// <param name="currentUrl"></param> IEnumerator LoadUrlIntoPreview(string currentUrl) { if (currentAnimatedGifComponent != null) { currentAnimatedGifComponent.RemoveUIImageFromUpdate(previewImage); } if (!animatedTextureCompCache.ContainsKey(currentUrl)) { currentAnimatedGifComponent = gameObject.AddComponent <AnimatedGifTexture>(); yield return(currentAnimatedGifComponent.LoadAndShowGif(currentUrl, previewImage)); animatedTextureCompCache.Add(currentUrl, currentAnimatedGifComponent); textureCache.Add(currentUrl, currentAnimatedGifComponent.GetTexture()); } else { currentAnimatedGifComponent = animatedTextureCompCache[currentUrl]; currentAnimatedGifComponent.AddImageToUpdate(previewImage); previewImage.material.SetTexture("_MainTex", textureCache[currentUrl]); previewImage.material.SetTextureOffset("_MainTex", new Vector2(0f, 0f)); previewImage.material.SetTextureScale("_MainTex", new Vector2(currentAnimatedGifComponent.GetOffsetStep(), 1f)); previewImage.SetMaterialDirty(); } }