public bool TryGetCachedImage(DataEntityHandle handle, out Texture2D icon, string context) { icon = null; string hashName = createHash(handle, context); if (imageCache.ContainsImage(hashName)) { icon = imageCache.GetTextureFromCache(hashName); return(true); } return(false); }
protected bool RequestImage(RenderParams renderParams, RequestImageCallback callback) { CallbackToken callbackToken = renderParams.CallbackToken; if (completionCallbacks.ContainsKey(callbackToken)) { completionCallbacks[callbackToken].Add(callback); return(false); } if (imageCache.ContainsImage(renderParams.ImageHash)) { Texture2D textureFromCache = imageCache.GetTextureFromCache(renderParams.ImageHash); callback(success: true, textureFromCache, callbackToken); return(true); } List <RequestImageCallback> list = new List <RequestImageCallback>(); list.Add(callback); completionCallbacks.Add(callbackToken, list); renderQueue.Enqueue(renderParams); if (renderQueue.Count == 1) { CoroutineRunner.Start(setupAndProcessRequests(), this, "ProcessNextRequest"); } return(false); }