| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using GFGGame.Launcher;
- using System.Collections.Generic;
- using YooAsset;
- namespace GFGGame
- {
- public class PreloadManager : SingletonMonoBase<PreloadManager>
- {
- private List<string> waitList = new List<string>();
- private ResourceDownloaderOperation downloaderOperation;
- private string[] locationsLoading;
- public void Add(string location)
- {
- waitList.Add(location);
- }
- private void Update()
- {
- if(downloaderOperation != null)
- {
- if(downloaderOperation.IsDone)
- {
- foreach(var t in locationsLoading)
- {
- LoadManager.Instance.SetResDownloaded(t);
- }
- downloaderOperation = null;
- locationsLoading = null;
- }
- }
- if(downloaderOperation == null)
- {
- waitList.Reverse();//看了yooasset源码,疑似他是从后往前加载,这里翻转一下
- locationsLoading = waitList.ToArray();
- downloaderOperation = YooAssets.CreateBundleDownloader(locationsLoading, 1, 3);
- downloaderOperation.BeginDownload();
- waitList.Clear();
- }
- }
- }
- }
|