# UnityHttpPlugin **Repository Path**: GameDevLee/HttpPlugin ## Basic Information - **Project Name**: UnityHttpPlugin - **Description**: 基于Unity的Http服务,完全封装UnityWebRequest,可以快速便捷的Get,Post,下载文件,下载图片等功能 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 2 - **Created**: 2022-09-06 - **Last Updated**: 2025-06-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HttpService **联系作者:419731519(QQ)** ### ============HttpService介绍============ #### 基于UnityWebRequest的基础上,封装了多个Http的异步接口 #### 使得可以非常方便的使用Get,Post,DownloadFile,DownloadSprite #### 觉得我的插件能帮助到你,麻烦帮我点个Star支持一下❤️ ### =================使用方法================= - manifest.json中添加插件路径 ```json { "dependencies": { "com.leeframework.httpservice":"https://e.coding.net/ggdevlee/leeframework/HttpService.git#1.0.5" } } ``` - 引入命名空间 ```csharp using LeeFramework.Http; ``` - Get ```csharp HttpSvc.instance.Get("http:", (cb) => { if (cb.isError) { Debug.Log(cb.errorMsg); return; } Debug.Log(cb.json); }); ``` - Post ```csharp HttpSvc.instance.Post("http:", (cb) => { if (cb.isError) { Debug.Log(cb.errorMsg); return; } Debug.Log(cb.json); }, "key", "json"); ``` - DownloadFile ```csharp HttpSvc.instance.DownloadFile("https:", (value) => { HttpFileCb fileCb = value; if (!fileCb.isError) { File.WriteAllBytes(Application.dataPath + "/../aaa.png", fileCb.data); } else { Debug.LogError(fileCb.errorMsg); } }); ``` - DownloadSprite ```csharp HttpSvc.instance.DownloadSprite("https:", (value) => { HttpSpriteCb spriteCb = value; if (!spriteCb.isError) { img.sprite = spriteCb.sprite; } else { Debug.LogError(spriteCb.errorMsg); } }); ``` - 创建文件下载任务 ```csharp DownloadFileItem item = HttpSvc.instance.DownloadFailTask("https://", (value) => { HttpFileCb fileCb = value; if (!fileCb.isError) { File.WriteAllBytes(Application.dataPath + "/../aaa.png", fileCb.data); } else { Debug.LogError(fileCb.errorMsg); } }); //item Todo item.StartDownload(); ``` - 创建图片下载任务 ```csharp DownloadSpriteItem sprite = HttpSvc.instance.DownloadSpriteTask("https://", (value) => { HttpSpriteCb spriteCb = value; if (!spriteCb.isError) { img.sprite = spriteCb.sprite; } else { Debug.LogError(spriteCb.errorMsg); } }); //item Todo sprite.StartDownload(); ```