/// <summary> /// 反初始化 /// </summary> public override void Uninitialize() { StopAllCoroutines(); _resCache = null; //_repaireMachine = null; _packConfig = null; }
//弱引用资源恢复工具 //RepaireMachine _repaireMachine; /// <summary> /// 初始化 /// </summary> /// <returns></returns> public override bool Initialize() { _resCache = new ResCache(); //_repaireMachine = new RepaireMachine(); _packConfig = null; return(true); }
/// <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); } } }
/// <summary> /// 加载资源包打包信息 /// </summary> public void LoadResPackConfig(byte[] filebytes) { if (_packConfig == null) { _packConfig = new ResPackConfig(filebytes); } else { _packConfig.ReloadDataBytes(filebytes); } }
/// <summary> /// 获取打包信息 /// </summary> /// <param name="path">资源路径</param> /// <returns></returns> BundlePackInfo GetPackInfo(string path) { if (string.IsNullOrEmpty(path)) { return(null); } ResPackConfig config = ResService.GetInstance().PackConfig; if (config == null) { return(null); } return(config.GetPackInfoForResource(path) as BundlePackInfo); }
/// <summary> /// 合并配置 /// </summary> /// <param name="fileName"></param> public void MergeResPackConfig(string fileName) { if (JW.Res.FileUtil.IsExistInIFSExtraFolder(fileName)) { string resPackFile = JW.Res.FileUtil.CombinePath(JW.Res.FileUtil.GetIFSExtractPath(), fileName); byte[] bbs = JW.Res.FileUtil.ReadFile(resPackFile); ResPackConfig otherCfg = new ResPackConfig(bbs, true); if (_packConfig != null) { _packConfig.MergeWithOther(otherCfg); } bbs = null; } else { JW.Common.Log.LogD("ResService MergeResPackConfig No File Exist:" + fileName); } }