# UnityDownloadService **Repository Path**: GameDevLee/unitydownloadservice ## Basic Information - **Project Name**: UnityDownloadService - **Description**: 基于Unity协程的下载服务,支持断点续传下载图片,文件,AB包等,支持实时更新下载进度 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-08-29 - **Last Updated**: 2023-08-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 

Simple Icons

DownloadService

## 介绍 基于**Unity**协程的下载服务 支持下载**文件,AB包,图片,文件断点续传,下载数据** 一行代码,直接下载文件,不需要初始化 支持**实时**回调下载进度 支持下载失败,**自动重新下载** 支持链式调用,随时随地,直接添加多个回调! ***觉得我的插件能帮助到你,不妨请我喝杯咖啡或者点个Star⭐支持一下,有你的支持,我才能继续做出更好的插件❤️*** Simple Icons **☎️商务合作/联系作者:419731519(QQ)** ### 安装插件 - **Packages/manifest.json**中添加以下行: ```json { "dependencies": { "com.leeframework.downloadservice":"https://e.coding.net/ggdevlee/leeframework/DownloadService.git#1.0.0" } } ``` ### 如何使用? Unity - 引入命名空间 ```csharp using LeeFramework.Download; ``` - 下载AB包 ```csharp DownloadSvc.DownloadAB("https://xxx/xxx.ab", (res, downloader) => { if (res) { AssetBundle ab = downloader.GetAssetBundle(); } else { Debug.LogError("下载AB失败"); } }).OnProgress((progress)=> { Debug.LogFormat("下载AB进度:{0}", progress); }); ``` - 下载文件 ```csharp DownloadSvc.DownloadFile("https://xxx/xxx.txt", Application.persistentDataPath + "/Test.txt", (res, downloader) => { if (res) { //获取数据 byte[] data = downloader.GetData(); //获取txt string txt = downloader.GetText(); } else { Debug.LogError("下载失败"); } }).OnProgress((progress) => { Debug.LogFormat("下载文件进度:{0}", progress); }); ``` - 下载数据 ```csharp DownloadSvc.DownloadData("https://xxx/xxx.txt", (res, downloader) => { if (res) { //获取数据 byte[] data = downloader.GetData(); //获取txt string txt = downloader.GetText(); } else { Debug.LogError("下载失败"); } }).OnProgress((progress)=> { Debug.LogFormat("下载文件进度:{0}", progress); }); ``` - 下载图片 ```csharp DownloadSvc.DownloadTexture("https://xxx/xxx.png", (res, downloader) => { if (res) { //返回Sprite Sprite sprite = downloader.GetSprite(); //返回Texture Texture texture = downloader.GetTexture(); } else { Debug.LogError("下载失败"); } }).OnProgress((progress) => { Debug.LogFormat("下载文件进度:{0}", progress); }); ``` - 断点续传文件 ```csharp DownloadSvc.ResumeDownloadFile("https://xxx/xxx.png", Application.persistentDataPath + "/AAA.png", Application.persistentDataPath + "/AAA.png.tmp", (res, downloader) => { if (res) { //获取数据 byte[] data = downloader.GetData(); //获取txt string txt = downloader.GetText(); } else { Debug.LogError("下载失败"); } }).OnProgress((progress) => { Debug.LogFormat("下载文件进度:{0}", progress); }); ```