Beispiel #1
0
    //协程-下载更新包
    IEnumerator Coroutine_DownloadUpdatePackage()
    {
        while (DownIndex < UpdateList.Count)
        {
            XML_PackMD5.Info info = UpdateList[DownIndex];
            ++DownIndex;
            bool isSucc = false;
            if (long.Parse(info.FileSize) != 0)
            {//下载
                string filename = info.PackName;
                string url      = ResPath.GetServerPackURL(filename);
                WWW    down     = new WWW(url);
                while (!down.isDone)
                {
                    yield return(down);
                }
                if (down.isDone && down.error == null)
                {
                    if (ResUtil.SaveFile(down.bytes, ResPath.LocalPackagePath, filename))
                    {//保存文件成功
                        isSucc = true;
                    }
                    else
                    {//保存文件失败
                        Debug.LogWarning("save file failed! file = " + ResPath.LocalPackagePath + filename);
                    }
                }
                else
                {
                    Debug.LogWarning("download failed, url = " + url + ",isDone:" + down.isDone + ",error:" + down.error);
                }
            }
            else
            {
                isSucc = true;
            }
            if (isSucc)
            {//更新成功
                SuccList.Add(info);
                //更新本地
                PackMD5Local.Update(info);
                FilePackLocal.Update(info.PackName, FilePackRemote);
                PackDependLocal.Update(info.PackName, PackDependRemote);

                DownSize += long.Parse(info.FileSize);
            }
            else
            {
                FailList.Add(info);

                //DownSize += long.Parse(info.FileSize);
            }
        }
    }