Пример #1
0
        /// <summary>
        /// 立即卸载
        /// </summary>
        /// <param name="path"></param>
        void UnloadImmediately(string path)
        {
            BundleRef br = null;

            if (_bundleDict.TryGetValue(path, out br))
            {
                if (br.Bundle != null)
                {
                    br.Bundle.Unload(false);
                }

                _bundleDict.Remove(br.Path);
            }
        }
Пример #2
0
        /// <summary>
        /// 移除最早的资产
        /// </summary>
        /// <returns></returns>
        public string RemoveEarliestNetAssetInfo()
        {
            if (_cachedAssetInfos.Count <= 0)
            {
                return(null);
            }

            NetAssetInfo info = _cachedAssetInfos[0];

            _cachedAssetInfos.RemoveAt(0);
            _cachedAssetInfoMap.Remove(info.Key);

            return(info.Key);
        }
Пример #3
0
        /// <summary>
        /// 合并
        /// </summary>
        /// <param name="other"></param>
        public void MergeWithOther(ResPackConfig other)
        {
            if (_resourceMap == null || other == null)
            {
                return;
            }

            //先清理
            for (int i = 0; i < other.PackInfo.Count; ++i)
            {
                ResPackInfo resPackInfo = other.PackInfo[i];
                //
                for (int j = PackInfo.Count - 1; j >= 0; j--)
                {
                    if (PackInfo[j].Path == resPackInfo.Path)
                    {
                        PackInfo.RemoveAt(j);
                    }
                }
            }
            //添加
            for (int i = 0; i < other.PackInfo.Count; ++i)
            {
                ResPackInfo resPackInfo = other.PackInfo[i];
                PackInfo.Add(resPackInfo);

                List <ResInfo> resInfos = resPackInfo.Resources;
                for (int resIndex = 0; resIndex < resInfos.Count; ++resIndex)
                {
                    ResInfo res = resInfos[resIndex];
                    if (!_resourceMap.ContainsKey(res.Path))
                    {
                        _resourceMap.Add(res.Path, resPackInfo);
                    }
                    else
                    {
                        //Log.LogE("Pack Config {0} and {1}:{2}had same res : {3}", "Main", "Other", resPackInfo.Path, res.Path);
                        //替换
                        Log.LogD("Reload ResPackInfo:");
                        _resourceMap.Remove(res.Path);
                        _resourceMap.Add(res.Path, resPackInfo);
                    }
                }
            }

            //后处理下依赖
            for (int i = 0; i < PackInfo.Count; ++i)
            {
                ResPackInfo resPackInfo = PackInfo[i];
                if (resPackInfo != null)
                {
                    resPackInfo.ProcessDependency(this.PackInfo);
                }
            }
        }
 private void OnDiffFileDownloaded(bool isError, uint sessionId, bool isEnd, float progress)
 {
     if (isError)
     {
         JW.Common.Log.LogE("IFS OnDiffFileDownloaded Error:" + sessionId.ToString());
         _errorCnt++;
         //目前都成功计数
         if (_diffDownloadInfo != null)
         {
             _diffDownloadInfo.Remove(sessionId);
         }
         _diffDownloadedCnt++;
     }
     else
     {
         if (_diffDownloadInfo != null && isEnd)
         {
             _diffDownloadInfo.Remove(sessionId);
             _diffDownloadedCnt++;
         }
     }
 }
        /// <summary>
        /// 移除资源对象
        /// </summary>
        /// <param name="resource">资源对象</param>
        /// <param name="immediately">是否立即删除</param>
        /// <returns>true:表示所有同路径资源都已移除完</returns>
        public bool Remove(ResObj resource, bool immediately)
        {
            if (resource == null)
            {
                return(true);
            }

            if (_resources.ContainsKey(resource.OriginPath))
            {
                if (immediately)
                {
                    resource.Unload();
                    _resources.Remove(resource.OriginPath);
                    ResObj.Recycle(resource);

                    return(true);
                }
                else
                {
                    if (resource.RefCnt > 0)
                    {
                        resource.RefCnt--;
                    }
                    else
                    {
                        JW.Common.Log.LogE("Unloading resource [{0}] while its reference count is zero.", resource.Path);
                    }

                    return(resource.RefCnt <= 0);
                }
            }
            else
            {
                resource.Unload();
                ResObj.Recycle(resource);
                return(true);
            }
        }