void Update() { // Collect all the finished WWWs. var remoteList = new List <string>(); var keys = cache.WwwCache.Keys; foreach (var key in keys) { WWW download = cache.WwwCache[key]; // 下载失败 if (download.error != null) { com.QH.QPGame.GameUtils.Logger.Res.LogError(key + " load failed!!!! Error:" + download.error + " URI:" + download.url); cache.ErrorCache.Add(key, download.error); remoteList.Add(key); } // 下载成功 else if (download.isDone) { com.QH.QPGame.GameUtils.Logger.Res.Log(key + " loaded:" + download.assetBundle.name + " URI:" + download.url); LOAssetBundle ab = new LOAssetBundle(download.assetBundle, key); cache.SetBundleCache(key, ab); //download.assetBundle.Unload(false); remoteList.Add(key); } } foreach (var ab in remoteList) { cache.WwwCache[ab].Dispose(); cache.WwwCache.Remove(ab); } }
/// <summary> /// 检查是否已经从网络下载 /// </summary> protected WWW IsLoadAssetBundleAtInternal(string assetBundleName) { //已经存在了呀 LOAssetBundle bundle = LOAssetCache.GetBundleCache(assetBundleName); if (bundle != null) { //保留一次 bundle.Retain(); return(null); } //如果WWW缓存策略中包含有对应的关键字,则返回null if (LOAssetCache.InWWWCache(assetBundleName)) { return(null); } //创建下载链接 WWW www = new WWW(LOAssetManager.URI + assetBundleName); //加入缓存策略 LOAssetCache.SetWWWCache(assetBundleName, www); return(www); }
/// <summary> /// /// </summary> /// <returns>The asset.</returns> public T GetAsset <T>(string assetbundlename, string assetname) where T : UnityEngine.Object { LOAssetBundle lab = LOAssetCache.GetBundleCache(assetbundlename); if (lab == null) { return(null); } else { return(lab.m_AssetBundle.LoadAsset <T>(assetname)); } }
internal void SetBundleCache(string key, LOAssetBundle value) { BundleCache.Add(key, value); }
internal static void SetBundleCache(string key,LOAssetBundle value) { LOAssetCache.BundleCache.Add(key,value); }
internal static void SetBundleCache(string key, LOAssetBundle value) { LOAssetCache.BundleCache.Add(key, value); }