Exemple #1
0
 public void OnDownLoadBatchProgress(DownLoadBatch downLoadBatch, DownLoaderBese downLoaderBese)
 {
     if (onAssetUpdateProgress != null)
     {
         onAssetUpdateProgress(downLoadBatch);
     }
 }
Exemple #2
0
    public void AddDownLoadBatch(DownLoadBatch downLoadBatch)
    {
        for (int i = 0; i < downLoadBatch.downLoaderArr.Count; i++)
        {
            AddDownLoader(downLoadBatch.downLoaderArr [i]);
        }

        downLoadBatchs.Add(downLoadBatch);
    }
Exemple #3
0
        void OnAssetsUpdateProgress(DownLoadBatch dlb)
        {
            Debug.Log("DownLoad Progress...");
            if (dlb != null)
            {
                UnityEngine.UI.Slider sl = View.getCurrentProgressControll();
                if (sl != null)
                {
                    sl.value = (float)dlb.progress;
                }
            }
//			else
//			{
//
//			}
        }
Exemple #4
0
    void OnDownLoadBatchError(DownLoadBatch downLoadBatch, DownLoaderBese downLoaderBese)
    {
        /*
         * 如果在本次下载批次中出现错误,则还原备份的 md5filelist.txt.bak
         * 当程序再次加载时忽略本次下载结果
         */
        string localFilePath    = assetsUpdatePath + "/md5filelist.txt";
        string localFilePathbak = assetsUpdatePath + "/md5filelist.txt.bak";

        //如果本地文件存在
        if (File.Exists(localFilePath) && File.Exists(localFilePathbak))
        {
            File.Delete(localFilePath);
            //还原旧列表
            File.Move(localFilePathbak, localFilePath);
        }

        if (_arrayNeedUpdate != null && _arrayNeedUpdate.Length > 0)
        {
            _arrayNeedUpdate = null;
        }
    }
Exemple #5
0
    void OnUpdateAssetsCmp(DownLoadBatch downLoadBatch)
    {
        File.AppendAllText(assetsUpdatePath + "/" + updateAssetsFileName, string.Format("已完成!{0} ", DateTime.Now.ToString("F", new System.Globalization.CultureInfo("zh-cn"))));

        string localMD5BakFilePath = assetsUpdatePath + "/md5filelist.txt.bak";

        string localMD5FilePath = assetsUpdatePath + "/md5filelist.txt";

        //删除临时备份文件
        if (File.Exists(localMD5BakFilePath))
        {
            if (!File.Exists(localMD5FilePath))
            {
                File.Move(localMD5BakFilePath, localMD5FilePath);
                Debug.LogWarningFormat("OnUpdateAssetsCmp add {0} ", localMD5FilePath);
            }
            else
            {
                File.Delete(localMD5BakFilePath);
                Debug.LogWarningFormat("OnUpdateAssetsCmp delete {0} ", localMD5BakFilePath);
            }
        }
        else
        {
            Debug.LogErrorFormat("OnUpdateAssetsCmp md5filelist.txt.bak not exists! in {0}", assetsUpdatePath);
        }

        if (onAssetsUpdateCmp != null)
        {
            //更新完成回调
            onAssetsUpdateCmp();
        }

        if (_arrayNeedUpdate != null && _arrayNeedUpdate.Length > 0)
        {
            _arrayNeedUpdate = null;
        }
    }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        //DownLoadManager.I.Add();

        DownLoadBatch downLoadBatch = new DownLoadBatch("DownLoadBatch",
                                                        OnDownLoadBatchCmp, OnDownLoadBatchError, OnDownLoadProgress);
        string url      = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png";
        string saveFile = Application.streamingAssetsPath + "/" + System.IO.Path.GetFileName(url);

        downLoadBatch.Add(url, saveFile);
        string url2      = "https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/r/image/2017-09-15/ecdbc5929ce5b9e974ea1b876875df6a.png";
        string saveFile2 = Application.streamingAssetsPath + "/" + System.IO.Path.GetFileName(url2);

        downLoadBatch.Add(url2, saveFile2);

        string url3      = "http://127.0.0.1/thunder_mac_3.1.7.3266.dmg";
        string saveFile3 = Application.streamingAssetsPath + "/" + System.IO.Path.GetFileName(url3);

        //downLoadBatch.Add(url3, saveFile3);

        downLoadBatch.Execute();

        UpZip("/Library/WebServer/Documents/data.zip", "/Users/zhuyuu3d/Documents/webroot/unzip");
    }
Exemple #7
0
    void UpdateAssets(string[] needUpdate)
    {
        DownLoadBatch downLoadBatch = new DownLoadBatch("AssetsUpdateManager.UpdateAssets",
                                                        OnUpdateAssetsCmp,
                                                        OnDownLoadBatchError,
                                                        OnDownLoadBatchProgress);

        string line;

        for (int i = 0; i < needUpdate.Length; i++)
        {
            line = needUpdate[i];
            if (line.IndexOf("=") >= 0)
            {
                string path = line.Substring(0, line.IndexOf("="));
                string md5  = line.Substring(line.IndexOf("=") + 1);

                //downLoadBatch.Add(Path.Combine(assetsSeverUrl,path),Path.Combine(assetsUpdatePath,path),md5);
                downLoadBatch.Add(assetsSeverUrl + path, assetsUpdatePath + path, md5);
            }
        }

        downLoadBatch.Execute();
    }
Exemple #8
0
 void OnDownLoadBatchError(DownLoadBatch downLoadBatch, DownLoaderBese downLoaderBese)
 {
     Debug.LogError("下载错误! " + downLoadBatch.name);
 }
Exemple #9
0
 void OnDownLoadBatchCmp(DownLoadBatch downLoadBatch)
 {
     Debug.Log("下载完成: " + downLoadBatch.name);
 }
Exemple #10
0
 void OnDownLoadProgress(DownLoadBatch downLoadBatch, DownLoaderBese downLoaderBese)
 {
 }
Exemple #11
0
 public void RemDownLoadBatch(DownLoadBatch downLoadBatch)
 {
     downLoadBatchs.Remove(downLoadBatch);
 }