当前位置:网站首页>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);
}
}
}
边栏推荐
- Mongodb creates an implicit database as an exercise
- Do you have a boss to help look at this error report and what troubleshooting ideas are there? Oracle CDC 2.2.1 flick 1.14.4
- Check the example of where the initialization is when C initializes the program
- STM32中AHB总线_APB2总线_APB1总线这些是什么
- Performance optimization record of the company's product "yunzhujia"
- 嵌入式背景知识-芯片
- Can I open a stock trading account online? Is it safe
- Agile course training
- Sword finger offer II 107 Distance in matrix
- AI moves from perception to intelligent cognition
猜你喜欢

The landing practice of ByteDance kitex in SEMA e-commerce scene

高数_第1章空间解析几何与向量代数_向量的数量积

request对象对请求体,请求头参数的解析

Delete a record in the table in pl/sql by mistake, and the recovery method

Postman interface test I

ORM -- grouping query, aggregation query, query set queryset object properties

STM32中AHB总线_APB2总线_APB1总线这些是什么

Pytest learning - dayone

Fiddler simulates the interface test
![[untitled]](/img/5b/61efbaded29250bc8d921b0cf087c8.png)
[untitled]
随机推荐
每周推荐短视频:L2级有哪些我们日常中经常会用到的功能?
Fiddler break point
“十二星座女神降临”全新活动推出
A wave of open source notebooks is coming
14th test
Apprentissage avancé des fonctions en es6
MySQL can connect locally through localhost or 127, but cannot connect through intranet IP (for example, Navicat connection reports an error of 1045 access denied for use...)
Some test points about coupon test
ORM model -- associated fields, abstract model classes
为什么安装mysql时starting service报错?(操作系统-windows)
Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
Phpcms realizes PC website access to wechat native payment
位操作==c语言2
CDZSC_ 2022 winter vacation personal training match level 21 (1)
arcgis操作:dwg数据转为shp数据
字节跳动 Kitex 在森马电商场景的落地实践
Codeforces - 1324d pair of topics
Huffman encoded compressed file
Analyze Android event distribution mechanism according to popular interview questions (I)
官媒关注!国内数字藏品平台百强榜发布,行业加速合规健康发展