public AsyncResourceRequest(string url, PoolUnitCacheTag cacheTag, Action <Object> callback, Action <AsnycLoadRequestBase> reportManager) { this.url = url; this.cacheTag = cacheTag; this.reportManager = reportManager; this.callback = callback; loader = LoadResourceAsync(url); }
public AsyncAssetBundleRequest(string url, string assetName, PoolUnitCacheTag cacheTag, Action <Object> callback, Action <AsnycLoadRequestBase> reportManager) { this.url = url; this.cacheTag = cacheTag; this.reportManager = reportManager; this.callback = callback; loader = LoadAssetBundleAsync(url, assetName); }
public void SetData(string index, object data, PoolUnitCacheTag cacheTag = PoolUnitCacheTag.CacheUntilClean) { if (dataPool.ContainsKey(index)) { dataPool[index] = new PoolUnit <object>(data, cacheTag); } else { dataPool.Add(index, new PoolUnit <object>(data, cacheTag)); } }
public T GetResource <T>(string url, PoolUnitCacheTag cacheTag) where T : Object { if (assetPool.ContainsKey(url)) { return(assetPool[url].Storage as T); } var asset = Resources.Load <T>(url); AddAssetPoolUnit(url, cacheTag, asset); return(asset as T); }
public void GetAssetBundleAsync(string url, string assetName, PoolUnitCacheTag cacheTag, Action <Object> callback) { if (assetPool.ContainsKey(url)) { callback(assetPool[url].Storage); } else { if (asyncLoadRequests.ContainsKey(url)) { return; } var request = new AsyncAssetBundleRequest(url, assetName, cacheTag, callback, ReportLoadRequestResult); asyncLoadRequests.Add(url, request); StartCoroutine(request.Loader); } }
/// <summary> /// Add unit into asset pool. /// </summary> private void AddAssetPoolUnit(string url, PoolUnitCacheTag cacheTag, Object asset) { if (cacheTag == PoolUnitCacheTag.DontCache) { return; } if (url == "") { throw new InvalidOperationException("AddAssetPoolUnit - url is empty"); } if (asset == null) { throw new NullReferenceException("AddAssetPoolUnit - asset is null"); } assetPool.Add(url, new PoolUnit <Object>(asset, cacheTag)); }
public T GetAssetBundle <T>(string url, string assetName, PoolUnitCacheTag cacheTag) where T : Object { if (assetPool.ContainsKey(url)) { return(assetPool[url].Storage as T); } var assetBundle = AssetBundle.LoadFromFile(url); if (assetBundle == null) { throw new NullReferenceException("Load asset bundle failed : " + url); } var asset = assetBundle.LoadAsset(assetName); AddAssetPoolUnit(url, cacheTag, asset); assetBundle.Unload(false); return(asset as T); }
public void GetResourceAsync <T>(string url, PoolUnitCacheTag cacheTag, Action <Object> callback) where T : Object { //var request = Resources.LoadAsync<T>(url); }
public PoolUnit(T storage, PoolUnitCacheTag cacheTag) { this.storage = storage; this.cacheTag = cacheTag; }