/// <summary> /// 编译列表文件 /// </summary> /// <param name="path">路径</param> protected static void BuildListFile(string path) { CUpdateList lst = new CUpdateList(path); path.Walk((file) => { if (!file.Standard().EndsWith(".meta")) { string fullName = file.Standard(); string assetName = fullName.Substring(path.Length); lst.Append(assetName, CMD5.ParseFile(file), file.Length); } }); lst.Save(); }
/// <summary> /// 获取文件更新列表 /// </summary> /// <returns></returns> protected IEnumerator UpdateList(string resUrl) { base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_START); resUrl = resUrl + "/" + CEnv.PlatformToName(CEnv.SwitchPlatform); UnityWebRequest request = UnityWebRequest.Get(resUrl + "/" + CUpdateList.FILE_NAME); yield return(request.Send()); if (request.isError || request.responseCode != 200) { this.isUpdate = false; base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_LIST_FAILED); yield break; } base.Event.Trigger(CAutoUpdateEvents.ON_SCANNING_DISK_FILE_HASH_START); var newLst = new CUpdateList(request).SetPath(CEnv.AssetPath); CUpdateList oldLst = new CUpdateList(CEnv.AssetPath); CDirectory.CreateDir(CEnv.AssetPath); CDirectory.Walk(CEnv.AssetPath, (file) => { if (!file.Standard().EndsWith(".meta")) { string fullName = file.Standard(); string assetName = fullName.Substring(CEnv.AssetPath.Length); oldLst.Append(assetName, CMD5.ParseFile(file), file.Length); } }); base.Event.Trigger(CAutoUpdateEvents.ON_SCANNING_DISK_FILE_HASH_END); CUpdateList needUpdateLst, needDeleteLst; oldLst.Comparison(newLst, out needUpdateLst, out needDeleteLst); yield return(this.DeleteOldAsset(needDeleteLst)); yield return(this.UpdateAssetFromUrl(needUpdateLst, resUrl)); newLst.Save(); base.Event.Trigger(CAutoUpdateEvents.ON_UPDATE_COMPLETE); }