public void EnsureTextureMaxSize(WrappedTextureMaxSize maxTextureSize) { if (maxTextureSize != WrappedTextureMaxSize.DONT_RESIZE) { gif.SetMaxTextureSize((int)maxTextureSize); } }
public void EnsureTextureMaxSize(WrappedTextureMaxSize maxTextureSize) { if (maxTextureSize != WrappedTextureMaxSize.DONT_RESIZE) { TextureHelpers.EnsureTexture2DMaxSize(ref texture2D, (int)maxTextureSize); } }
public static IEnumerator FetchWrappedTextureAsset(string url, Action <IWrappedTextureAsset> OnSuccess, WrappedTextureMaxSize maxTextureSize = WrappedTextureMaxSize.DONT_RESIZE) { string contentType = null; byte[] bytes = null; yield return(Utils.FetchAsset(url, UnityWebRequest.Get(url), (request) => { contentType = request.GetResponseHeader("Content-Type"); bytes = request.downloadHandler.data; })); if (contentType != null && bytes != null) { yield return(WrappedTextureAssetFactory.Create(contentType, bytes, maxTextureSize, OnSuccess)); } }
static public IEnumerator Create(string contentType, byte[] bytes, WrappedTextureMaxSize maxTextureSize, Action <IWrappedTextureAsset> OnSuccess) { if (contentType == "image/gif") { var gif = new DCLGif(); yield return(gif.Load(bytes, () => { var wrappedGif = new WrappedGif(gif); wrappedGif.EnsureTextureMaxSize(maxTextureSize); gif.Play(); OnSuccess?.Invoke(wrappedGif); })); } else { var texture = new Texture2D(1, 1); texture.LoadImage(bytes); var wrappedImage = new WrappedImage(texture); wrappedImage.EnsureTextureMaxSize(maxTextureSize); OnSuccess?.Invoke(wrappedImage); } }