|
@@ -1,17 +1,30 @@
|
|
|
using System.Threading.Tasks;
|
|
|
using YooAsset;
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
|
public class LoadManager : SingletonBase<LoadManager>
|
|
|
{
|
|
|
- public async Task CheckResExsitedAndLoad(string location)
|
|
|
+ private Dictionary<string, bool> checkStatusDic = new Dictionary<string, bool>();
|
|
|
+
|
|
|
+ public bool CheckResExsited(string location)
|
|
|
{
|
|
|
- if (string.IsNullOrEmpty(location) || !YooAssets.IsNeedDownloadFromRemote(location))
|
|
|
+ if (string.IsNullOrEmpty(location))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ checkStatusDic.TryGetValue(location, out bool exsited);
|
|
|
+ return exsited;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task CheckResExsitedOrDownload(string location)
|
|
|
+ {
|
|
|
+ if(CheckResExsited(location))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- var downloaderOperation = YooAssets.CreateBundleDownloader(new string[] { location}, 3, 3);
|
|
|
+ ResourceDownloaderOperation downloaderOperation = YooAssets.CreateBundleDownloader(new string[] { location}, 3, 3);
|
|
|
if (downloaderOperation.TotalDownloadCount == 0)
|
|
|
{
|
|
|
//文件已在本地,不需要下载
|
|
@@ -21,7 +34,13 @@ namespace GFGGame
|
|
|
//下载
|
|
|
downloaderOperation.BeginDownload();
|
|
|
await downloaderOperation.Task;
|
|
|
+ checkStatusDic[location] = true;
|
|
|
ViewManager.Hide<ModalStatusView>();
|
|
|
}
|
|
|
+
|
|
|
+ public void SetResDownloaded(string location)
|
|
|
+ {
|
|
|
+ checkStatusDic[location] = true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|