Example #1
0
        public IEnumerator TryCacheSpriteSheetImage(string id, string uri, ImageRect rect, Action <EnhancedImageInfo> Finally = null, int forcedHeight = -1)
        {
            if (_cachedImageInfo.TryGetValue(id, out var info))
            {
                Finally?.Invoke(info);
                yield break;
            }
            if (!_cachedSpriteSheets.TryGetValue(uri, out var tex) || tex == null)
            {
                yield return(DownloadContent(uri, (bytes) => tex = GraphicUtils.LoadTextureRaw(bytes)));

                _cachedSpriteSheets[uri] = tex;
            }
            CacheSpriteSheetImage(id, rect, tex, Finally, forcedHeight);
        }
Example #2
0
        public void TryCacheSpriteSheetImage(string id, string uri, ImageRect rect, Action <EnhancedImageInfo> Finally = null, int forcedHeight = -1)
        {
            if (_cachedImageInfo.TryGetValue(id, out var info))
            {
                Finally?.Invoke(info);
                return;
            }

            if (_cachedSpriteSheets.TryGetValue(uri, out var tex))
            {
                CacheSpriteSheetImage(id, rect, tex, Finally, forcedHeight);
            }
            else
            {
                StartCoroutine(ChatImageProvider.instance.DownloadContent(uri, (bytes) =>
                {
                    Logger.log.Info($"Finished download content for emote {id}!");
                    var tex = GraphicUtils.LoadTextureRaw(bytes);
                    _cachedSpriteSheets[uri] = tex;

                    CacheSpriteSheetImage(id, rect, tex, Finally, forcedHeight);
                }));
            }
        }