Пример #1
0
    private void DoDownLoad(string strUrl, System.Action callBack)
    {
        Debug.Log("_DownLoad  " + strUrl);
        HttpDownLoad _aHttpDownLoad = new HttpDownLoad();

        _aHttpDownLoad.DownLoad(strUrl, ResourceManager.Instance.PersistentDataPath, callBack);
    }
Пример #2
0
    void downloads()
    {
        GameObject middleLastObj = Middle.transform.GetChild(Middle.transform.childCount - 1).gameObject;

        if (middleLastObj == gameObject)
        {
            if (file == false)
            {
                http3 = new HttpDownLoad();                                                  //下载bundle并LoadScene
                http3.DownLoad(RemoteIP + fileName, savePath, fileName, http3DownLoadState); //BUndle下载优先级最高
            }
            else
            {
                load += func;
                if (file == true)
                {
                    if (returnHall == false)
                    {
                        func();
                    }
                    else
                    {
                        GameObject load = Instantiate(gameContrall.instant.Loading, GameObject.Find("Canvas").transform) as GameObject;
                        gameContrall.instant.catchFish(changci, gameObject);
                    }
                }
            }

            start_download = true;
        }
    }
Пример #3
0
        public void DownLoadServerVersionInfomation()
        {
            if (!couldDownLoadServerVersion)
            {
                return;
            }
            couldDownLoadServerVersion = false;
            var http = new HttpDownLoad();

            http.DownLoad(this.serverDownloadUrl + versionFileName, localDownLoadRoot, versionFileNameTmp, true, DownloadVersionCallback);
        }
Пример #4
0
    //下载 ab  包
    private void DownLoadSignGroup(string resource_path, string tartget_path)
    {
        OperaStatus = AppOperState.Downloading;
        DebugLog.DebugLogInfo("开启下载" + this_app.app_type);
        if (File.Exists(tartget_path))
        {
            DebugLog.DebugLogInfo("删除文件  ");
            File.Delete(tartget_path);
        }
        http = new HttpDownLoad();
        //开启下载,能取消下载
        show_progress.Set_Progress("资源下载中...", CancelDownload);

        DebugLog.DebugLogInfo(resource_path + "  " + tartget_path);
        //下载源路径文件到  目标地址,进行回调验证下载完成
        http.DownLoad(resource_path, tartget_path, DownLoad_complete, download_error);
    }
Пример #5
0
    //下载切换
    void DownSwitch()
    {
        string tmpName = Ready_Download_list[ndr].name;
        string tmpUrl  = Ready_Download_list[ndr].url;//+ "?v=" + System.DateTime.Now;

        string filePath;

        switch (Ready_Download_list[ndr].type.ToLower())
        {
        case "anim_ab":
            filePath = PublicClass.Anim_TimelinePath + tmpName;
            PublicClass.Anim_ABPath = filePath;
            break;

        case "ab":
            filePath = PublicClass.filePath + tmpName;
            break;

        case "db":
            filePath = PublicClass.vesal_db_path + tmpName;
            break;

        case "update":
            filePath = PublicClass.filePath + tmpName;
            break;

        case "lua":
            filePath = PublicClass.filePath + tmpName;
            Vesal_DirFiles.ClearFolder(PublicClass.xluaPath);
            break;

        default:
            filePath = PublicClass.filePath + tmpName;
            break;
        }


        Debug.Log("当前下载资源:" + tmpName + " 路径:" + tmpUrl + "version " + Ready_Download_list[ndr].version);
        Vesal_DirFiles.DelFile(filePath);

        if (!http.DownLoad(tmpUrl, filePath, Download, Download_error))
        {
            Unity_Tools.ui_return_to_platform();
            Application.Quit(); //下载过程中,连接断开,重连失败
        }
    }
Пример #6
0
    void Start()
    {
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
        savePath = Application.persistentDataPath;
#elif UNITY_ANDROID
        savePath = Application.persistentDataPath;
#endif
        //开启两个http进行文件下载
        http1 = new HttpDownLoad();
        http1.DownLoad(RemoteIP1, savePath, fileName1, http1DownLoadState);

        http2 = new HttpDownLoad();
        http2.DownLoad(RemoteIP2, savePath, fileName2, http2DownLoadState);

        http3 = new HttpDownLoad();                                                                                  //下载bundle并LoadScene
        http3.DownLoad(RemoteIP3, savePath, fileName3, http3DownLoadState, System.Threading.ThreadPriority.Highest); //BUndle下载优先级最高
    }
Пример #7
0
    private async void StartDownload()
    {
        isFinished = false;
        tip        = "文件将安装到互动课堂资源目录";

        var state = model.GetState();

        fileName = Path.GetFileName(state.filePath);
        var savepath = Path.Combine(Application.persistentDataPath, fileName).Replace('\\', '/');

        state.progress = 0;
        model.SetState(state);

        httpDownLoad = new HttpDownLoad(state.filePath, Application.persistentDataPath, 8000);
        httpDownLoad.DownLoad();
        await new WaitForSeconds(0.5f);
        filesize = HumanReadableFilesize(httpDownLoad.TotalLength);
        httpDownLoad.OnComplete = () =>
        {
            isFinished = true;
        };
        Update();
    }
Пример #8
0
 void Start()
 {
     savePath = Application.streamingAssetsPath;
     http     = new HttpDownLoad();
     http.DownLoad(url, savePath, LoadLevel);
 }
Пример #9
0
    IEnumerator Start()
    {
        DownloadDetail currentLoad  = null;
        HttpDownLoad   httpDownLoad = new HttpDownLoad();

        while (true)
        {
            if (currentLoad != null)
            {
                if (currentLoad.url.StartsWith("https"))
                {
                    ///请求https不会返回下载的总大小(在gitee上测试的)
                    ///因此不返回下载进度
                    if (currentLoad.downloadingCallback != null)
                    {
                        currentLoad.downloadingCallback(1);
                    }
                    UnityWebRequest unityWebRequest = new UnityWebRequest(currentLoad.url)
                    {
                        downloadHandler = new DownloadHandlerBuffer()
                    };
                    yield return(unityWebRequest.Send());

                    if (currentLoad.downloadingCallback != null)
                    {
                        currentLoad.downloadingCallback(1);
                    }

                    System.IO.File.WriteAllBytes(string.Format("{0}/{1}", currentLoad.savePath, currentLoad.fileName), unityWebRequest.downloadHandler.data);
                    unityWebRequest.downloadHandler.Dispose();

                    if (currentLoad.callback != null)
                    {
                        currentLoad.callback();
                    }

                    currentLoad = null;
                }
                else
                {
                    httpDownLoad.DownLoad(currentLoad.url, currentLoad.savePath, currentLoad.fileName, currentLoad.callback);
                    while (!httpDownLoad.isDone)
                    {
                        if (currentLoad.downloadingCallback != null)
                        {
                            currentLoad.downloadingCallback(httpDownLoad.progress);
                        }
                        yield return(GameData.EndOfFrame);
                    }

                    if (currentLoad.callback != null)
                    {
                        currentLoad.callback();
                    }

                    currentLoad = null;
                }
            }
            else
            {
                lock (lockObject)
                {
                    if (_downList.Count > 0)
                    {
                        currentLoad = _downList[0];
                        _downList.RemoveAt(0);
                    }
                }
            }
            yield return(GameData.EndOfFrame);
        }
    }