示例#1
0
        public void Start()
        {
            if (GameEnvironment.Instance.config.Platform == GamePlatform.Editor || GameEnvironment.Instance.config.Platform == GamePlatform.Windows || GameEnvironment.Instance.config.Platform == GamePlatform.Mac)
            {
                path.diskPath = path.diskPath.Replace("file://", "");
            }

            if (File.Exists(path.diskPath))
            {
                File.Delete(path.diskPath);
            }

            if (!Directory.Exists(path.dirPath))
            {
                Directory.CreateDirectory(path.dirPath);
            }

            fileStream = new FileStream(path.diskPath, FileMode.Append);

            HFLog.L(name + " 开始下载  ");
            HFLog.L(name + " path.url  " + path.url);
            HFLog.L(name + " path.diskPath  " + path.diskPath);

            request                    = new HTTPRequest(new Uri(path.url), OnRequest);
            request.OnProgress         = OnUploadProgress;
            request.Timeout            = new TimeSpan(0, 0, 20);
            request.ConnectTimeout     = new TimeSpan(0, 0, 20);
            request.UseStreaming       = true;
            request.StreamFragmentSize = 1 * 256 * 256;
            request.DisableCache       = true;
            request.Send();
        }
示例#2
0
        public void Start()
        {
            if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
            {
                currentPath.localPath = currentPath.localPath.Replace("file://", "");
            }

            if (File.Exists(currentPath.localPath))
            {
                HFLog.L(currentTaskName + "文件存在 删除!" + currentPath.localPath);
                File.Delete(currentPath.localPath);
            }


            request                    = new HTTPRequest(new Uri(currentPath.webUrl), OnRequest);
            request.OnProgress         = OnUploadProgress;
            request.Timeout            = new TimeSpan(0, 0, 20);
            request.ConnectTimeout     = new TimeSpan(0, 0, 20);
            request.UseStreaming       = true;
            request.StreamFragmentSize = 1 * 256 * 256;
            request.DisableCache       = true;
            request.Send();


            /*
             * using (WebClient client = new WebClient())
             * {
             *  client.DownloadProgressChanged += WebClientDownloadProgressChanged;
             *  client.DownloadFileCompleted += WebClientDownloadCompleted;
             *  client.DownloadFileAsync(new Uri(currentPath.webUrl), currentPath.localPath);
             * }
             */
        }
示例#3
0
 private void StartDownLoadTask(string taskName, WebUrlLocalPath paths, Action <string> simpleTaskFinish)
 {
     HFLog.L(taskName + "被创建了");
     this.currentTaskName  = taskName;
     this.currentPath      = paths;
     this.simpleTaskFinish = simpleTaskFinish;
     Start();
 }
示例#4
0
 public void UnloadAssetBundle(AssetPackage bundle, bool unloadAllLoadedObjects = true)
 {
     if (GameEnvironment.Instance.config.LoadAssetPathType != LoadAssetPathType.Editor)
     {
         HFLog.L("卸载Assetbundle  " + bundle.name);
         bundle.unloading = true;
         ReleaseAssetBundle(bundle.name);
         allAssetBundleDic.Remove(bundle.name);
         bundle.Unload(unloadAllLoadedObjects);
     }
 }
示例#5
0
 private void DownLoadFile(WebUrlLocalPath path)
 {
     StartDownLoadTask("Task" + currentTaskIndex, path, delegate(string taskName)
     {
         HFLog.L("单个下载完成");
         if (currentTaskIndex < taskCount - 1)
         {
             if (progress != null)
             {
                 progress((currentTaskIndex + 1.0f) / taskCount);
             }
             currentTaskIndex++;
             DownLoadFile(allTaskPath[currentTaskIndex]);
         }
         else
         {
             progress(1);
             DownLoadManager.Instance.currentDownLoadCount--;
             HFLog.L("所有下载队列下载完成");
         }
     });
 }