private List <ABUnit> CalculateDeleteList(AssetDataTable local, AssetDataTable remote) { if (remote == null || local == null) { return(null); } var remoteABList = remote.GetAllABUnit(); //防止远程清单文件下载失败导致本地被删光 if (remoteABList.Count == 0) { return(null); } List <ABUnit> localABList = local.GetAllABUnit(); List <ABUnit> deleteABList = new List <ABUnit>(); for (int i = localABList.Count - 1; i >= 0; --i) { ABUnit localABUnit = localABList[i]; ABUnit remoteABUnit = remote.GetABUnit(localABUnit.abName); if (remoteABUnit == null) { deleteABList.Add(localABUnit); continue; } } return(deleteABList); }
public bool GetAssetBundlePath(string assetName, out string result) { result = null; ABUnit unit = GetABUnit(assetName); if (unit == null) { return(false); } result = m_FolderPath + unit.abName; return(true); }
public bool GetAssetBundleDepends(string abName, out string[] result) { result = null; ABUnit unit = GetABUnit(abName); if (unit == null) { return(false); } result = unit.abDepends; return(true); }
public ABUnit GetABUnit(string name) { ABUnit result = null; for (int i = m_AllAssetDataPackages.Count - 1; i >= 0; --i) { result = m_AllAssetDataPackages[i].GetABUnit(name); if (result != null) { break; } } return(result); }
private void OnResUpdateFinish(bool result, IRes res) { ABUnit unit = null; if (m_UpdateUnitMap.TryGetValue(res.name, out unit)) { if (!result) { Log.e("Update Res Failed:" + res.name); m_UpdateFailedList.Add(unit); return; } m_AlreadyUpdateFileSize += unit.fileSize; ++m_AlreadyUpdateFileCount; m_Record.AddRecord(unit.abName, unit.md5, unit.fileSize, unit.buildTime); } }
private void ProcessNewInstall() { bool isNewInstall = CheckIsNewInstall(); Log.i("Check Is New Install:" + isNewInstall); if (isNewInstall) { //对比外部文件 List <string> outResult = new List <string>(); FilePath.GetFileInFolder(FilePath.persistentDataPath4Res, ProjectPathConfig.abConfigfileName, outResult); AssetDataTable exterTable = new AssetDataTable(); for (int i = 0; i < outResult.Count; ++i) { exterTable.LoadPackageFromFile(outResult[i]); } //生成差异文件列表: List <ABUnit> needDeleteList = ABUnitHelper.CalculateLateList(exterTable, AssetDataTable.S, false); for (int i = 0; i < needDeleteList.Count; ++i) { ABUnit unit = needDeleteList[i]; string exterFilePath = ProjectPathConfig.AssetBundleName2ExterUrl(unit.abName); if (File.Exists(exterFilePath)) { File.Delete(exterFilePath); } } var packages = AssetDataTable.S.allAssetDataPackages; if (packages.Count > 0) { var package = packages[0]; PlayerPrefs.SetString(INNER_RES_PACKAGE, package.key); PlayerPrefs.SetInt(INNER_RES_BUILDTIME, (int)package.buildTime); PlayerPrefs.Save(); } } }
//计算成成更新的资源列表 public static List <ABUnit> CalculateLateList(AssetDataTable oldData, AssetDataTable newData, bool addNew) { if (newData == null || oldData == null) { return(null); } List <ABUnit> newABUnitList = newData.GetAllABUnit(); List <ABUnit> lateABList = new List <ABUnit>(); for (int i = newABUnitList.Count - 1; i >= 0; --i) { ABUnit newUnit = newABUnitList[i]; ABUnit oldUnit = oldData.GetABUnit(newUnit.abName); if (oldUnit == null) { //更新的新资源 if (addNew) { lateABList.Add(newUnit); } continue; } if (oldUnit.md5.Equals(newUnit.md5)) { continue; } if (oldUnit.buildTime < newUnit.buildTime) { lateABList.Add(newUnit); } } return(lateABList); }
public void ModifyAssetDataTable(AssetDataTable table) { RecordCell cell = null; AssetDataPackage package = null; for (int i = 0; i < m_UpdateRecordList.Count; ++i) { cell = m_UpdateRecordList[i]; ABUnit unit = table.GetABUnit(cell.name); if (unit == null) { table.AddAssetBundleName(cell.name, null, cell.md5, 1, cell.buildTime, out package); continue; } else { unit.buildTime = cell.buildTime; unit.md5 = cell.md5; unit.fileSize = cell.fileSize; } } }