联系作者:419731519(QQ)
- manifest.json中添加插件路径
{
"dependencies": {
"com.leeframework.httpservice":"https://e.coding.net/ggdevlee/leeframework/HttpService.git#1.0.4"
}
}
- 引入命名空间
using LeeFramework.Http;
- Get
HttpSvc.instance.Get("http:", (cb) =>
{
if (cb.isError)
{
Debug.Log(cb.errorMsg);
return;
}
Debug.Log(cb.json);
});
- Post
HttpSvc.instance.Post("http:", (cb) =>
{
if (cb.isError)
{
Debug.Log(cb.errorMsg);
return;
}
Debug.Log(cb.json);
}, "key", "json");
- DownloadFile
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
HttpSvc.instance.DownloadSprite("https:", (value) =>
{
HttpSpriteCb spriteCb = value;
if (!spriteCb.isError)
{
img.sprite = spriteCb.sprite;
}
else
{
Debug.LogError(spriteCb.errorMsg);
}
});
- 创建文件下载任务
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();
- 创建图片下载任务
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();