Пример #1
0
        public static void GetModGalleryImage(ModProfile profile,
                                              string imageFileName,
                                              ModGalleryImageSize size,
                                              Action <Texture2D> onSuccess,
                                              Action <WebRequestError> onError)
        {
            var cachedImageTexture = CacheClient.LoadModGalleryImage(profile.id,
                                                                     imageFileName,
                                                                     size);

            if (cachedImageTexture != null)
            {
                if (onSuccess != null)
                {
                    onSuccess(cachedImageTexture);
                }
            }
            else
            {
                // - Fetch from Server -
                var download = DownloadClient.DownloadModGalleryImage(profile,
                                                                      imageFileName,
                                                                      size);

                download.succeeded += (d) =>
                {
                    CacheClient.SaveModGalleryImage(profile.id, imageFileName, size, d.imageTexture);
                };

                download.succeeded += (d) => onSuccess(d.imageTexture);
                download.failed    += (d) => onError(d.error);
            }
        }