/// <summary> /// Get Cached Asset /// </summary> /// <param name="assetPath">Path to asset. Should be handle-able by the asset locator</param> /// <returns>Task that returns the cached asset</returns> public async Task <ICachedAsset> GetAsync(string assetPath) { //Get or create cache entry if (!CacheDictionary.TryGetValue(assetPath, out var entry)) { entry = new AssetCacheEntry(assetPath, LocateAssetAsync(assetPath), _assetLoader.Unload); CacheDictionary.Add(assetPath, entry); } //Wait for the task to finish if (!entry.Task.IsCompleted) { await entry.Task; } return(entry.GetCachedAsset()); }
public CachedAsset(AssetCacheEntry entry) { _disposed = false; _cacheEntry = entry; _cacheEntry.Increment(); }