Example #1
0
 //检查更新
 public bool CheckUpdate(GameResManager.CheckUpdateCallback callback)
 {
     if (Entry == null)
     {
         return(false);
     }
     //清除更新残留数据
     ClearUpdateData();
     Entry.StartCoroutine(Coroutine_DownloadVersion(callback));
     return(true);
 }
Example #2
0
    //协程 下载版本
    IEnumerator Coroutine_DownloadVersion(GameResManager.CheckUpdateCallback callback)
    {
        string url     = ResPath.GetServerURL(ResPath.VersionFileName);
        WWW    downVer = new WWW(url);

        while (!downVer.isDone)
        {
            yield return(downVer);
        }
        if (downVer.isDone && downVer.error == null)
        {
            //保存版本文件到临时目录下
            if (ResUtil.SaveFile(downVer.bytes, ResPath.LocalTempCachePath, ResPath.VersionFileName))
            {
                //比较本地版本和server版本
                VersionInfo verLocal  = new VersionInfo(ResPath.LocalPath + ResPath.CurrentPathName + ResPath.VersionFileName);
                VersionInfo verServer = new VersionInfo(ResPath.LocalTempCachePath + ResPath.VersionFileName);

                if (0 > VersionInfo.CompareVersion(verLocal, verServer))
                {//服务器版本较新,更新
                    DownXmlCount = 3;
                    Entry.StartCoroutine(Coroutine_DownloadPackMD5());
                    Entry.StartCoroutine(Coroutine_DownloadFilePack());
                    Entry.StartCoroutine(Coroutine_DownloadPackDepend());
                    while (DownXmlCount > 0)
                    {//下载xml文件中
                        yield return(new WaitForSeconds(1));
                    }
                    UpdateList = XML_PackMD5.GetUpdateList(PackMD5Remote, PackMD5Local, out TotalSize);
                }
            }
        }
        else
        {
            Debug.LogWarning("WWW failed, url:" + url + ", isDone:" + downVer.isDone + ", error:" + downVer.error);
        }
        //回调
        callback(UpdateList != null && UpdateList.Count > 0);
    }