void StartDownload() { //string url = "http://woda.jijiagames.com/cdn/wod_android_1.0.0.227915_200321_1804_pr2v6_update/"; string url = "https://down.qq.com/wod/cdn/wod_android_1.0.0.227915_200321_1804_pr2v6_update/"; Debug.Log(Application.persistentDataPath); List <string> files = new List <string>() { "0e3b671686680b573737c89a6f2c251f.zip", "0f4f049806f0e5f6f4ba2583ae7efb07.zip", "1c81d60584f69db4c294699421c84549.zip", "1c67094f3671f16a636c77636e979a98.zip", "1ccfb16671d241eaacc145f55b923252.zip", "2a26c158c6c4533dcfd04285a77f8369.zip", "2d472e915235e8174e1a1f3fc74b0656.zip", "2f631b41f6f31db87da7d941fb0027fe.zip", "6a6783933b4a8d5de63a3bdc53878289.zip" }; for (int i = 0; i < files.Count; ++i) { DownLoadTask task = new DownLoadTask(); task.url = url + files[i]; task.path = task.url.Replace(url, Application.persistentDataPath + "/"); DownLoadManager.GetInstance().DoTask(task); } StartCoroutine(WaitDownLoad()); SetState(DownloadState.Download); }
private void StartDownLoad(GameResFileInfo resInfo) { if (IsLoading) { return; } IsLoading = true; IsDone = false; Progress = 0; gameResInfo = resInfo; string localfolderPath = URLFactory.GetLocalGameResSaveFolder(resInfo.gameName); string tagfolderPath = URLFactory.GetLocalGameTagFolder(resInfo.gameName); if (!Directory.Exists(localfolderPath)) { Directory.CreateDirectory(localfolderPath); } if (!Directory.Exists(tagfolderPath)) { Directory.CreateDirectory(tagfolderPath); } TotalBytesKB = 0; foreach (DownLoadFileInfo info in resInfo.infoList) { if (DownLoadManager.CheckOnceFileInfo(info) != GameVersionState.NewestVersion) { DownLoadThread downLoadThread = new DownLoadThread(); downLoadThreadList.Add(downLoadThread); downLoadThread.StartDownLoad(info); TotalBytesKB += info.size; } } }
public static DownLoadManager initForGameObject(GameObject dontDestroyOnLoadGameObject) { if (instance == null) { instance = dontDestroyOnLoadGameObject.AddComponent <DownLoadManager>(); } return(instance); }
public static DownLoadManager GetInstance() { if (s_instance == null) { GameObject insObj = new GameObject(); GameObject.DontDestroyOnLoad(insObj); s_instance = insObj.AddComponent <DownLoadManager>(); } return(s_instance); }
public static DownLoadManager getInstance() { if (instance == null) { GameObject gameObject = new GameObject("DownLoadManager"); DontDestroyOnLoad(gameObject); instance = gameObject.AddComponent <DownLoadManager>(); } return(instance); }
void OnClick() { switch (state) { case DownloadState.WaitStart: { StartDownload(); } break; case DownloadState.WaitContine: { DownLoadManager.GetInstance().Continue(); } break; } }
/// <summary> /// 释放资源 /// </summary> public void CheckExtractResource() { string basePath = Util.BuildAssetsPath; bool isExists = Directory.Exists(basePath) && Directory.Exists(basePath + "lua/") && File.Exists(basePath + "files.txt"); m_DownLoadManager = new DownLoadManager(); //Debug.Log(m_DownLoadManager); if (isExists || AppConst.DebugMode) { StartCoroutine(OnUpdateResource()); return; //文件已经解压过了,自己可添加检查文件列表逻辑 } StartCoroutine(OnExtractResource()); //启动释放协成 }
///// <summary> ///// 线程下载 ///// </summary> //void BeginDownload(string url, string file) //{ // //线程下载 // object[] param = new object[2] {url, file}; // ThreadEvent ev = new ThreadEvent(); // ev.Key = NotiConst.UPDATE_DOWNLOAD; // ev.evParams.AddRange(param); // ThreadManager.AddEvent(ev, OnThreadCompleted); //线程下载 //} ///// <summary> ///// 线程完成 ///// </summary> ///// <param name="data"></param> //void OnThreadCompleted(NotiData data) //{ // switch (data.evName) // { // case NotiConst.UPDATE_EXTRACT: //解压一个完成 // // // break; // case NotiConst.UPDATE_DOWNLOAD: //下载一个完成 // downloadFiles.Add(data.evParam.ToString()); // break; // } //} /// <summary> /// 资源初始化结束 /// </summary> public void OnResourceInited() { #if ASYNC_MODE //ResManager.Initialize("LuaBundles", delegate() ResManager.Initialize(AppConst.AssetDir, delegate() { Debug.Log("Initialize OK!!!"); this.OnInitialize(); }); #else ResManager.Initialize(); this.OnInitialize(); #endif //下载完成,释放DownLoadManager if (m_DownLoadManager != null) { m_DownLoadManager.OnStopThread(); m_DownLoadManager = null; } }
IEnumerator CheckingUpdate(CheckComplete onComplete, bool useCache, bool needRetry) { ReleaseCheckLoader(); string tuf = GetServerUrl(LoaderManager.byteFileInfoFileName + BaseBundle.sSuffixName); string tcheckfile = GetCheckFileName(); string tfilePath = GameCore.CombinePath(GameCore.PersistentResDataPath, tcheckfile); if (!useCache || !File.Exists(tfilePath)) { checkLoader = DownLoadManager.DownLoadFileAsync(tuf, GameCore.PersistentResDataPath, tcheckfile, null, 0, null); while (!checkLoader.IsDone) { yield return(null); } DownLoadCheckFileEnd(checkLoader, onComplete, useCache, needRetry); } else { DownLoadCheckFileFinished(onComplete); } }
IEnumerator CheckingUpdate(CheckComplete onComplete, bool useCache, bool needRetry) { ReleaseCheckLoader(); string tdicpath = string.Format("{0}/{1}/", updateData.server, updateData.version); string tuf = GetServerUrl(LoadManager.byteFileInfoFileName + LoadManager.sSuffixName); string tcheckfile = GetCheckFileName(); string tfilePath = CombinePath(LoadManager.sidePath, tcheckfile); if (!useCache || !File.Exists(tfilePath)) { checkLoader = DownLoadManager.DownLoadFileAsync(tuf, LoadManager.sidePath, tcheckfile, null, 0, null); while (!checkLoader.IsDone) { yield return(null); } DownLoadCheckFileEnd(checkLoader, onComplete, useCache, needRetry); } else { DownLoadCheckFileFinished(onComplete); } }
IEnumerator WaitDownLoad() { WaitForSeconds waitForSeconds = new WaitForSeconds(0.2f); while (true) { bool isPause = DownLoadManager.GetInstance().IsPause(); bool isFailed = DownLoadManager.GetInstance().IsFaied(); long downLoadSize = DownLoadManager.GetInstance().GetDownLoadSize(); long speed = DownLoadManager.GetInstance().GetSpeed(); if (isPause) { if (!isFailed) { text_progress.text = "下载成功"; SetState(DownloadState.WaitStart); UpdateText(); break; } else { if (state != DownloadState.WaitContine) { text_progress.text = "下载中断,等待继续..."; SetState(DownloadState.WaitContine); } } } else { text_progress.text = string.Format("下载中..{0}, 速度:{1}/s", FileUtils.ByteToString(downLoadSize), FileUtils.ByteToString(speed)); } yield return(waitForSeconds); } yield return(null); }
private void Awake() { Instance = this; }
static async Task Main(string[] args) { DownLoadManager manager = new DownLoadManager(); await manager.ChooseTypeAction(); }
protected override void Init() { downLoadMgr = DownLoadManager.Instance; }