Exemple #1
0
    public override IEnumerator StartDownload(System.Action callback = null)
    {
        base.StartDownload();

        m_www             = new WWW(m_srcUrl);
        m_isStartDownload = true;
        yield return(m_www);

        //WWW读取完成后,才开始往下执行
        m_isStartDownload = false;

        if (m_www.isDone)
        {
            byte[] bytes = m_www.bytes;
            //创建文件
            FileTool.CreatFile(m_saveFilePath, bytes);
        }
        else
        {
            Debug.Log("Download Error:" + m_www.error);
        }

        if (callback != null)
        {
            callback();
        }
    }
Exemple #2
0
        void OnFileDownloadOver(UnityWebRequest www, object msg)
        {
            byte[] bytes    = www.downloadHandler.data;
            string filePath = Path.Combine(localBundlePath, msg.ToString());

            //创建文件
            Debug.Log("单个下载完成:" + filePath);
            FileTool.CreateDirectory(filePath);
            FileTool.CreatFile(filePath, bytes);
            filesStatus[msg.ToString()] = FILE_STATUS_UNKOWN;
        }
Exemple #3
0
 void OnGetRemoteVersion(bool succeed, string versionNum = null)
 {
     Debug.Log("读取版本号:" + succeed);
     // 获取了远程版本号
     if (null != versionNum)
     {
         Debug.Log("version:" + versionNum);
         if (curVersionNum != versionNum)
         {
             lastVersionNum = curVersionNum;
             curVersionNum  = versionNum;
             FileTool.CreatFile(localVersionFile, Encoding.ASCII.GetBytes(curVersionNum));
         }
         // 下载新的manifest文件
         localManifestPath   = Path.Combine(localBundlePath, curVersionNum);
         _localXManifestPath = localBundlePath + "/" + curVersionNum + ".xManifest";
         resUrlRoot          = patchUrl + "/" + Utility.GetPlatformName() + "/" + curVersionNum;
         if (!File.Exists(localManifestPath))
         {
             string manifestUrl = patchUrl + "/" + Utility.GetPlatformName() + "/" + curVersionNum + "/" + curVersionNum;
             Debug.Log(localBundlePath);
             DownloadManager dm = DownloadManager.instance;
             dm.OnError  += OnDownloadErr;
             dm.OnFinish += OnAllDownloadOver;
             curDownloadAllOverCallback = ManifestDownloadFinish;
             dm.OnFinish += curDownloadAllOverCallback;
             dm.Push(new DownloadManager.Request(manifestUrl, OnFileDownloadOver, localManifestPath));
             dm.Excute();
         }
         else
         {
             //进入下一步
             ManifestDownloadFinish();
         }
     }
     else
     {
         //未获取远程版本号
         Debug.LogError("获取远程版本号失败");
     }
 }