Ejemplo n.º 1
0
        public void DownloadOrLoadImage(ImageDownloadFormat format, string imageURL, string appDataFolderName, float loadingColorAlpha, Action onSuccess = null)
        {
            if (!string.IsNullOrEmpty(imageURL) && !string.IsNullOrEmpty(appDataFolderName))
            {
                _progressSpinner.gameObject.SetActive(true);
                Image image = Image;
                image.sprite = null;
                image.color  = ColorUtils.ColorWithAlpha(image.color, loadingColorAlpha);
                void onEnd()
                {
                    image.color = ColorUtils.ColorWithAlpha(image.color, 1f);
                    _progressSpinner.gameObject.SetActive(false);
                    onSuccess?.Invoke();
                }

                switch (format)
                {
                case ImageDownloadFormat.PNG_JPG:
                    ImageDownloader.DownloadIntoOrLoadFromFolder(appDataFolderName, Canvas, imageURL, image, onEnd);
                    break;

#if WEBP
                case ImageDownloadFormat.WebP:
                    DownloadIntoOrLoadWebPFromFolder(appDataFolderName, Canvas, imageURL, image, onEnd);
                    break;
#endif
                default:
                    break;
                }
            }
        }