DownloadMgr.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. using Game.Config;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Reflection;
  7. using System.Text;
  8. using UnityEngine;
  9. using UnityEngine.Networking;
  10. class LocalFilePathInfo
  11. {
  12. public string Path;
  13. /// <summary>
  14. /// 是否可读可写文件夹
  15. /// </summary>
  16. public bool IsLocalRW;
  17. public LocalFilePathInfo()
  18. {
  19. Path = "";
  20. IsLocalRW = false;
  21. }
  22. public LocalFilePathInfo(string path,bool rw)
  23. {
  24. Path = path;
  25. IsLocalRW = rw;
  26. }
  27. }
  28. public class DownloadMgr : Singleton<DownloadMgr>
  29. {
  30. public const int TimeOut = 60;
  31. private string downloadBaseUrl;
  32. private string downloadUrl;
  33. public string DownloadUrl { get => downloadUrl; }
  34. private int downloadTaskMaxNum;
  35. public int DownloadTaskMaxNum { get => downloadTaskMaxNum; }
  36. private string localFilePath;
  37. public string LocalFilePath { get => localFilePath; }
  38. private List<DownloadDataEntity> needDownloadList;
  39. private List<DownloadDataEntity> downloadSucessList;
  40. private List<DownloadDataEntity> remoteResList;
  41. private Dictionary<string, DownloadDataEntity> localResMap;
  42. private Dictionary<string, DownloadDataEntity> remoteResMap;
  43. private bool isInited = false;
  44. private GameDataFormatInfo downloadFormatInfo;
  45. private string versionFileName;
  46. private string assetsFileName;
  47. private string downloadedAssetsFileName;
  48. private ulong downloadSize;
  49. private ulong downloadingSize;
  50. public ulong DownloadSize { get => downloadSize + downloadingSize; }
  51. private ulong totalSize;//总大小
  52. public ulong TotalSize { get => totalSize; }
  53. public bool CheckFinish { get;private set; }
  54. public bool DowmloadError { get; private set; }
  55. //private byte[] versionData;
  56. //private byte[] mainfestData;
  57. private string versionData;
  58. //private UnityWebRequest mainfestData;
  59. public override void Init()
  60. {
  61. InitField();
  62. }
  63. private string GetIOSDownloadPath()
  64. {
  65. return "res/IosRes/";
  66. //#if GAME_DEBUG
  67. //#else
  68. //#endif
  69. }
  70. private string GetAndroidDownloadPath()
  71. {
  72. #if GAME_DEBUG
  73. return "res/TestServerRes/";
  74. #else
  75. return "res/AndroidNewRes/";
  76. #endif
  77. }
  78. private string GetDownloadBaseUrl()
  79. {
  80. #if GAME_ONE
  81. return "http://101.43.46.101:88/";
  82. #elif GAME_DEBUG
  83. return "http://110.40.223.119:88/";
  84. #else
  85. return "http://cxzcdn.hkhappygame.com/";
  86. #endif
  87. }
  88. private string GetDownloadUrl()
  89. {
  90. #if UNITY_IOS
  91. return GetDownloadBaseUrl() + GetIOSDownloadPath();
  92. #else
  93. return GetDownloadBaseUrl() + GetAndroidDownloadPath();
  94. #endif
  95. }
  96. private void InitField()
  97. {
  98. if (!isInited)
  99. {
  100. // //downloadBaseUrl = "http://cxzcdn.hkhappygame.com/";//"http://165.154.29.92:88/"; //http://cxzcdn.hkhappygame.com/res/
  101. // //downloadBaseUrl = "http://127.0.0.1:8060/";//"http://127.0.0.1:8060/";//
  102. //#if GAME_DEBUG
  103. // downloadBaseUrl = "http://110.40.223.119:88/";
  104. // downloadUrl = downloadBaseUrl + "res/TestServerRes/";
  105. //#else
  106. // downloadBaseUrl = "http://cxzcdn.hkhappygame.com/";
  107. //#if UNITY_IOS
  108. // downloadUrl = downloadBaseUrl + "res/IosRes/";
  109. //#else
  110. // downloadUrl = downloadBaseUrl + "res/AndroidNewRes/";
  111. //#endif
  112. //#endif
  113. downloadUrl = GetDownloadUrl();
  114. downloadTaskMaxNum = 3;
  115. localFilePath = GetLocalResPath();//FileSystem.LocalDocumentPath;
  116. #if UNITY_IOS
  117. versionFileName = "afivs";
  118. assetsFileName = "afimft";
  119. #else
  120. versionFileName = "Version";
  121. assetsFileName = "mainfest";
  122. #endif
  123. downloadedAssetsFileName = "downloaded";
  124. needDownloadList = new List<DownloadDataEntity>(100);
  125. downloadSucessList = new List<DownloadDataEntity>(100);
  126. remoteResList = new List<DownloadDataEntity>(1024);
  127. localResMap = new Dictionary<string, DownloadDataEntity>(1024);
  128. remoteResMap = new Dictionary<string, DownloadDataEntity>(1024);
  129. isInited = true;
  130. CheckFinish = false;
  131. DowmloadError = false;
  132. downloadSize = 0;
  133. downloadingSize = 0;
  134. totalSize = 0;
  135. }
  136. }
  137. public void CheckVersion()
  138. {
  139. AssetDownloader.Instance.DownLoadFileByCoroutine(GetRemoteUrl(versionFileName), webRqst =>
  140. {
  141. if (webRqst == null)
  142. {
  143. CheckFinish = true;
  144. DowmloadError = true;
  145. return;
  146. }
  147. byte[] data = webRqst.downloadHandler.data;
  148. //versionData = new byte[data.Length];
  149. //data.CopyTo(versionData,0);
  150. string version = Encoding.UTF8.GetString(data);
  151. Debug.Log("服务器 version = " + version);
  152. versionData = version;
  153. ReadDataFromFile(versionFileName,lVdatas=>
  154. {
  155. //OnloadedVersion(lVdatas, version);
  156. OnloadedLocalVersion(lVdatas, version);
  157. },true);
  158. });
  159. }
  160. public void DownLoadRemoteRes()
  161. {
  162. int size = needDownloadList.Count;
  163. int downsize = downloadSucessList.Count;
  164. downloadSize = 0;
  165. totalSize = 0;
  166. for (int i = 0; i < size; i++)
  167. {
  168. if (needDownloadList[i].FullName == "Version")
  169. {
  170. needDownloadList[i].State = DownloadTaskState.DownloadSuccess;
  171. continue;
  172. }
  173. totalSize += needDownloadList[i].Size;
  174. DownloadDataEntity entity = downloadSucessList.FindFirst(it=>it.FullName == needDownloadList[i].FullName);
  175. if (downsize > 0 && entity != null && entity.MD5 == needDownloadList[i].MD5)
  176. {
  177. needDownloadList[i].State = DownloadTaskState.DownloadSuccess;
  178. downloadSize += needDownloadList[i].Size;
  179. }
  180. else
  181. {
  182. needDownloadList[i].Callback = DownloadedCallback;
  183. needDownloadList[i].UpDateCallback = DownloadedUpdateCallback;
  184. AssetDownloader.Instance.AddDownloadTask(needDownloadList[i]);
  185. }
  186. }
  187. }
  188. public bool DownLoadFinish()
  189. {
  190. bool ret = true;
  191. int size = needDownloadList.Count;
  192. for (int i = 0; i < size; i++)
  193. {
  194. if (needDownloadList[i].State != DownloadTaskState.DownloadSuccess)
  195. {
  196. ret = false;
  197. }
  198. }
  199. return ret || DowmloadError;
  200. }
  201. public bool CheckNeedDownload()
  202. {
  203. return downloadSize < totalSize;
  204. }
  205. private void DownloadedUpdateCallback(DownloadTask task)
  206. {
  207. if (task == null)
  208. {
  209. DowmloadError = true;
  210. AssetDownloader.Instance.CancelDownLoad = true;
  211. return;
  212. }
  213. //Debug.Log($"下载:{downloadingSize}/{task.CurDownloadEntity.Size} 进度:{task.CurLoadProgress*100}%");
  214. downloadingSize = task.downloadSize;
  215. }
  216. private void DownloadedCallback(DownloadTask task)
  217. {
  218. if (task == null || downloadSucessList == null)
  219. {
  220. DowmloadError = true;
  221. AssetDownloader.Instance.CancelDownLoad = true;
  222. return;
  223. }
  224. DownloadDataEntity entity = null;
  225. entity = downloadSucessList.FindFirst(it => it.FullName == task.CurDownloadEntity.FullName);
  226. if (entity != null)
  227. {
  228. entity.MD5 = task.CurDownloadEntity.MD5;
  229. entity.Size = task.CurDownloadEntity.Size;
  230. }
  231. else
  232. {
  233. downloadSucessList.Add(task.CurDownloadEntity);
  234. }
  235. downloadingSize = 0;
  236. downloadSize += task.downloadSize;
  237. string savepath = localFilePath + downloadedAssetsFileName;
  238. CsvWriter<DownloadDataEntity> csvWriter = new CsvWriter<DownloadDataEntity>(savepath, "", downloadSucessList, downloadFormatInfo);
  239. csvWriter.Write();
  240. }
  241. private List<DownloadDataEntity> SerizlizeResList(byte[] data)
  242. {
  243. CsvReader csvReader = new CsvReader(FileHelper.GetName(assetsFileName), data);
  244. if (downloadFormatInfo == null)
  245. {
  246. downloadFormatInfo = new GameDataFormatInfo(csvReader.Fields(), csvReader.Types());
  247. }
  248. Type type = typeof(DownloadDataEntity);
  249. MethodInfo methodInfo = type.GetMethod("OnCsvLoad", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  250. methodInfo?.Invoke(null, new object[] { csvReader });
  251. List<DownloadDataEntity> resList = DownloadDataEntity.AllData();
  252. DownloadDataEntity.Clear();
  253. return resList;
  254. }
  255. private void GetRemoteResList()
  256. {
  257. string remoteversionpath = downloadUrl + assetsFileName;
  258. AssetDownloader.Instance.DownLoadFileByCoroutine(remoteversionpath, webRqst =>
  259. {
  260. if (webRqst == null)
  261. {
  262. CheckFinish = true;
  263. DowmloadError = true;
  264. return;
  265. }
  266. byte[] data = webRqst.downloadHandler.data;
  267. // mainfestData = new byte[data.Length];
  268. // data.CopyTo(mainfestData,0);
  269. //mainfestData = webRqst;
  270. List<DownloadDataEntity> reResList = SerizlizeResList(data);
  271. if (reResList != null)
  272. {
  273. OnRomoteListDownloaded(reResList);
  274. }
  275. });
  276. }
  277. private void OnRomoteListDownloaded(List<DownloadDataEntity> downloadDatas)
  278. {
  279. remoteResList.AddRange(downloadDatas);
  280. int size = downloadDatas.Count;
  281. for (int i = 0; i < size; i++)
  282. {
  283. remoteResMap.Add(downloadDatas[i].FullName, downloadDatas[i]);
  284. }
  285. //#if UNITY_IOS
  286. // ReadDataFromFile(assetsFileName, OnloadedLocalResList, false, 1);
  287. //#else
  288. // ReadDataFromFile(assetsFileName, OnloadedLocalResList);
  289. //#endif
  290. ReadDataFromFile(assetsFileName, OnloadedLocalResList);
  291. }
  292. //uint major
  293. //uint minor
  294. //uint release
  295. //uint patch
  296. private void SetCheckFinish()
  297. {
  298. versionData = null;
  299. CheckFinish = true;
  300. }
  301. private string GetLocalResPath()
  302. {
  303. string localPath = FileSystem.LocalDocumentPath;
  304. //#if UNITY_IOS
  305. // localPath = "file://" + localPath;
  306. //#endif
  307. return localPath;
  308. }
  309. private string GetStreamResPath()
  310. {
  311. string streamPath = FileSystem.LocalPackagePath;
  312. #if UNITY_IOS
  313. streamPath = "file://" + streamPath;
  314. #endif
  315. return streamPath;
  316. }
  317. private void OnloadedLocalVersion(byte[] datas, string version)
  318. {
  319. string lVersionstr = "0.0.0.0";
  320. if (datas != null)
  321. {
  322. lVersionstr = Encoding.UTF8.GetString(datas);
  323. }
  324. VersionCode lVersionCode = lVersionstr;//本地 local version
  325. VersionCode RVersionCode = version;// 远端 version
  326. string streamPath = GetStreamResPath();
  327. AssetDownloader.Instance.AssetLoadByCorutine(streamPath + versionFileName, filedatas =>
  328. {
  329. if (filedatas == null)
  330. {
  331. GetRemoteResList();
  332. Debug.Log("====== SVersionstr 为空 =====");
  333. return;
  334. }
  335. VersionCode SVersionCode;// stream data version
  336. string SVersionstr = Encoding.UTF8.GetString(filedatas);
  337. SVersionCode = SVersionstr;
  338. VersionCode localMaxCode = lVersionCode > SVersionCode ? lVersionCode : SVersionCode;
  339. if (localMaxCode == RVersionCode)
  340. {
  341. Debug.Log($"lVersionstr = {lVersionstr} SVersionstr = {SVersionstr} ===== version = {version} 不需要更新");
  342. SetCheckFinish();
  343. return;
  344. }
  345. if (localMaxCode >= RVersionCode && SVersionCode == localMaxCode)
  346. {
  347. Debug.Log($"lVersionstr = {lVersionstr} SVersionstr = {SVersionstr} ===== version = {version} 不需要跟新 需要删除之前下载资源");
  348. versionData = null;
  349. ReadDataFromFile(downloadedAssetsFileName, dlocaldatas =>
  350. {
  351. if (dlocaldatas != null)
  352. {
  353. List<DownloadDataEntity> localdownloadedList = SerizlizeResList(dlocaldatas);
  354. if (localdownloadedList != null && localdownloadedList.Count > 0)
  355. {
  356. downloadSucessList.AddRange(localdownloadedList);
  357. }
  358. DeleteDownloadFiles();
  359. }
  360. else
  361. {
  362. SetCheckFinish();
  363. }
  364. },true);
  365. }
  366. else
  367. {
  368. Debug.Log($"lVersionstr = {lVersionstr} SVersionstr = {SVersionstr} ===== version = {version} 需要更新");
  369. GetRemoteResList();
  370. //CheckFinish = true;
  371. }
  372. });
  373. }
  374. private void OnloadedVersion(byte[] datas,string version)
  375. {
  376. if (datas == null)
  377. {
  378. GetRemoteResList();
  379. Debug.Log("====== data 为空 =====");
  380. }
  381. else
  382. {
  383. string lVersionstr = Encoding.UTF8.GetString(datas);
  384. Debug.Log($"lVersionstr = {lVersionstr} ===== version = {version} ");
  385. if (lVersionstr == version)
  386. {
  387. Debug.Log($"lVersionstr = {lVersionstr} ===== version = {version} 不需要更新");
  388. SetCheckFinish();
  389. return;
  390. }
  391. else
  392. {
  393. VersionCode lVersionCode = lVersionstr;//本地 local version
  394. VersionCode RVersionCode = version;// 远端 version
  395. if (RVersionCode < lVersionCode)
  396. {
  397. SetCheckFinish();
  398. }
  399. else if (RVersionCode.major > lVersionCode.major || (RVersionCode.major == lVersionCode.major && RVersionCode.minor > lVersionCode.minor))
  400. {
  401. AssetDownloader.Instance.AssetLoadByCorutine(GetStreamResPath() + versionFileName, filedatas =>
  402. {
  403. VersionCode SVersionCode;// stream data version
  404. string SVersionstr = Encoding.UTF8.GetString(filedatas);
  405. SVersionCode = SVersionstr;
  406. if (SVersionCode >= RVersionCode && SVersionCode >= lVersionCode)
  407. {
  408. Debug.Log($"lVersionstr = {SVersionstr} ===== version = {version} 重新安装后需要删除之前资源");
  409. versionData = null;
  410. ReadDataFromFile(downloadedAssetsFileName, dlocaldatas=>
  411. {
  412. if (dlocaldatas != null)
  413. {
  414. List<DownloadDataEntity> localdownloadedList = SerizlizeResList(dlocaldatas);
  415. if (localdownloadedList != null && localdownloadedList.Count > 0)
  416. {
  417. downloadSucessList.AddRange(localdownloadedList);
  418. }
  419. DeleteDownloadFiles();
  420. }
  421. });
  422. }
  423. else
  424. {
  425. Debug.Log($"lVersionstr = {lVersionstr} ===== version = {version} 需要更新");
  426. GetRemoteResList();
  427. //CheckFinish = true;
  428. }
  429. });
  430. }
  431. else if (RVersionCode.release > lVersionCode.release || (RVersionCode.release == lVersionCode.release && RVersionCode.patch > lVersionCode.patch))
  432. {
  433. Debug.Log($"lVersionstr = {lVersionstr} ===== version = {version} 需要更新");
  434. GetRemoteResList();
  435. }
  436. else
  437. {
  438. SetCheckFinish();
  439. }
  440. }
  441. }
  442. }
  443. private void OnloadedLocalResList(byte[] datas)
  444. {
  445. if (datas == null)
  446. {
  447. }
  448. else
  449. {
  450. List<DownloadDataEntity> localList = SerizlizeResList(datas);
  451. if (localList != null)
  452. {
  453. int size = localList.Count;
  454. for (int i = 0; i < size; i++)
  455. {
  456. localResMap.Add(localList[i].FullName, localList[i]);
  457. }
  458. }
  459. }
  460. ReadDataFromFile(downloadedAssetsFileName, OnloadedDownloadResList);
  461. }
  462. private void OnloadedDownloadResList(byte[] datas)
  463. {
  464. if (datas != null)
  465. {
  466. List<DownloadDataEntity> localdownloadedList = SerizlizeResList(datas);
  467. if (localdownloadedList != null && localdownloadedList.Count > 0)
  468. {
  469. downloadSucessList.AddRange(localdownloadedList);
  470. }
  471. }
  472. GetNeedDownloadlist();
  473. DownLoadRemoteRes();
  474. }
  475. private List<DownloadDataEntity> GetLoacalResList(string path)
  476. {
  477. List<DownloadDataEntity> resList = null;
  478. if (System.IO.File.Exists(path))
  479. {
  480. byte[] data = System.IO.File.ReadAllBytes(path);
  481. resList = SerizlizeResList(data);
  482. }
  483. return resList;
  484. }
  485. private void GetNeedDownloadlist()
  486. {
  487. string ver = "Version";
  488. if (localResMap.ContainsKey(ver) && remoteResMap.ContainsKey(ver)&& localResMap[ver].MD5 == remoteResMap[ver].MD5)
  489. {
  490. Debug.Log("版本为最新状态");
  491. SetCheckFinish();
  492. //string savepath = localFilePath + downloadedAssetsFileName;
  493. //FileHelper.DeleteFile(savepath);
  494. return;
  495. }
  496. if (localResMap == null || localResMap.Count <= 0)
  497. {
  498. foreach (var item in remoteResMap)
  499. {
  500. needDownloadList.Add(item.Value);
  501. }
  502. }
  503. else
  504. {
  505. foreach (var item in remoteResMap)
  506. {
  507. if (item.Key == ver)
  508. {
  509. continue;
  510. }
  511. if (!localResMap.ContainsKey(item.Key) || localResMap[item.Key].MD5 != item.Value.MD5)
  512. {
  513. Debug.Log($"需跟新文件:{item.Value.FullName}");
  514. needDownloadList.Add(item.Value);
  515. }
  516. }
  517. }
  518. CheckFinish = true;
  519. }
  520. private string GetRemoteUrl( string name)
  521. {
  522. return downloadUrl + name;
  523. }
  524. private LocalFilePathInfo GetLocalFilePath(string name, bool onlyLocal = false, uint streamPerPath = 0)
  525. {
  526. LocalFilePathInfo ret = new LocalFilePathInfo();
  527. string path = LocalFilePath + name;
  528. ret.IsLocalRW = true;
  529. if (!FileSystem.Exists(path))
  530. {
  531. Debug.Log($" ========= LocalFilePath Path = {path} 不存在");
  532. if (!onlyLocal)
  533. {
  534. string lpPath = GetStreamResPath();
  535. for (int i = 0; i < streamPerPath; i++)
  536. {
  537. lpPath += "../";
  538. }
  539. path = lpPath + name;
  540. }
  541. ret.IsLocalRW = false;
  542. }
  543. ret.Path = path;
  544. Debug.Log($" ========= local Path = {path} ");
  545. return ret;
  546. }
  547. private void ReadDataFromFile(string name,Action<byte[]> callback,bool onlyLocal = false,uint streamPerPath = 0)
  548. {
  549. LocalFilePathInfo dlocalPath = GetLocalFilePath(name,onlyLocal, streamPerPath);
  550. if (dlocalPath.IsLocalRW)
  551. {
  552. try
  553. {
  554. byte[] dlocaldatas = File.ReadAllBytes(dlocalPath.Path);
  555. callback?.Invoke(dlocaldatas);
  556. }
  557. catch
  558. {
  559. Debug.Log("读取失败" + dlocalPath.Path);
  560. callback?.Invoke(null);
  561. }
  562. }
  563. else if(onlyLocal)
  564. {
  565. callback?.Invoke(null);
  566. }
  567. else
  568. {
  569. AssetDownloader.Instance.AssetLoadByCorutine(dlocalPath.Path, callback);
  570. }
  571. }
  572. private IEnumerator DeleteFiles()
  573. {
  574. ;
  575. int length = downloadSucessList.Count;
  576. string savepath = null;
  577. for (int i = 0; i < length; i++)
  578. {
  579. if (downloadSucessList[i].FullName == "font.unity3d")
  580. {
  581. Debug.Log("跳过删除");
  582. continue;
  583. }
  584. savepath = localFilePath + downloadSucessList[i].FullName;
  585. Debug.Log(savepath);
  586. FileHelper.DeleteFile(savepath);
  587. yield return null;
  588. }
  589. FileHelper.DeleteFile(localFilePath + downloadedAssetsFileName);
  590. yield return null;
  591. FileHelper.DeleteFile(localFilePath + versionFileName);
  592. yield return null;
  593. FileHelper.DeleteFile(LocalFilePath + assetsFileName);
  594. yield return null;
  595. SetCheckFinish();
  596. }
  597. public void DeleteDownloadFiles()
  598. {
  599. AssetDownloader.Instance.DoByCorutine(DeleteFiles);
  600. }
  601. public void Free()
  602. {
  603. //string savepath = localFilePath + downloadedAssetsFileName;
  604. //FileHelper.DeleteFile(savepath);
  605. if (!DowmloadError)
  606. {
  607. if( !string.IsNullOrEmpty(versionData))
  608. FileHelper.WirteStringToFile(localFilePath + versionFileName, versionData);
  609. //PlayerPrefs.SetString(versionFileName, versionData);
  610. //if(mainfestData!=null)
  611. // FileHelper.WirteToFile(LocalFilePath + assetsFileName, mainfestData.downloadHandler.data);
  612. if (remoteResList.Count > 0)
  613. {
  614. //Debug.Log($" ============= remoteResList.Count = {remoteResList.Count}" );
  615. CsvWriter<DownloadDataEntity> csvWriter = new CsvWriter<DownloadDataEntity>(LocalFilePath + assetsFileName, "", remoteResList, downloadFormatInfo);
  616. csvWriter.Write();
  617. }
  618. }
  619. needDownloadList = null;
  620. downloadSucessList = null;
  621. remoteResList = null;
  622. localResMap = null;
  623. remoteResMap = null;
  624. versionData = null;
  625. //mainfestData = null;
  626. AssetDownloader.Instance.ClearTasks();
  627. }
  628. }