当前位置:网站首页>Download Text, pictures and ab packages used by unitywebrequest Foundation
Download Text, pictures and ab packages used by unitywebrequest Foundation
2022-07-07 10:10:00 【Sunshine in front of my heart】
Get ready
UnityWebRequest
downloadHandler Is a download assistant , The downloaded resources can be obtained directly through it
UnityWebRequest Inherit IDisposable Interface
Be careful : The server you visit should have download permission To download
Download the text
IEnumerator LoadText(string url)
{
using (UnityWebRequest req = UnityWebRequest.Get(url))
{
yield return req.SendWebRequest();// issue get request
if (req.error == null)
{
Debug.Log(req.downloadHandler.text);
Debug.Log(req.downloadHandler.data.Length);
}
else
{
Debug.Log(" Download error " + req.responseCode + "," + req.error);
}
}
}
Download the pictures
IEnumerator LoadTexture(string url)
{
using (UnityWebRequest req = UnityWebRequestTexture.GetTexture(url))
{
yield return req.SendWebRequest();
if (req.error == null)
{
Debug.Log((req.downloadHandler as DownloadHandlerTexture).texture.width);
Debug.Log(DownloadHandlerTexture.GetContent(req).height);
}
else
{
Debug.Log(" Download error " + req.responseCode + "," + req.error);
}
}
}
download AB package
IEnumerator LoadAB(string url)
{
using (UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle(url))
{
yield return req.SendWebRequest();
if (req.error == null)
{
Debug.Log((req.downloadHandler as DownloadHandlerAssetBundle).assetBundle.name);
Debug.Log(DownloadHandlerAssetBundle.GetContent(req).name);
}
else
{
Debug.Log(" Download error " + req.responseCode + "," + req.error);
}
}
}
边栏推荐
- [original] what is the core of programmer team management?
- Become a "founder" and make reading a habit
- 网上可以开炒股账户吗安全吗
- Fiddler break point
- Web3.0 series distributed storage IPFs
- ISP、IAP、ICP、JTAG、SWD的编程特点
- ES6中的原型对象
- Before joining the chain home, I made a competitive product analysis for myself
- VS Code指定扩展安装位置
- Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
猜你喜欢

内存==c语言1

Postman interface test V

Internship log - day07

字节跳动 Kitex 在森马电商场景的落地实践

Applet popup half angle mask layer

Introduction to energy Router: Architecture and functions for energy Internet

官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展

Win10 installation vs2015

反卷积通俗详细解析与nn.ConvTranspose2d重要参数解释

LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
随机推荐
Postman tutorial - scripting
Why does the starting service report an error when installing MySQL? (operating system Windows)
喜马拉雅网页版每次暂停后弹窗推荐下载客户端解决办法
Applet popup half angle mask layer
ORM--逻辑关系与&或;排序操作,更新记录操作,删除记录操作
Use of JSON extractor originals in JMeter
ORM -- grouping query, aggregation query, query set queryset object properties
Interface test
XML配置文件解析与建模
为什么安装mysql时starting service报错?(操作系统-windows)
Web3.0 series distributed storage IPFs
第十四次试验
SolidWorks工程图中添加中心线和中心符号线的办法
单片机(MCU)最强科普(万字总结,值得收藏)
Apprentissage avancé des fonctions en es6
Pit using BigDecimal
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
ES6中的函数进阶学习
Basic chapter: take you through notes
LeetCode 练习——113. 路径总和 II