当前位置:网站首页>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);
}
}
}
边栏推荐
- 高数_第1章空间解析几何与向量代数_向量的数量积
- 为什么安装mysql时starting service报错?(操作系统-windows)
- Enterprise practice | construction of banking operation and maintenance index system under complex business relations
- ORM--查询类型,关联查询
- Please ask me a question. I started a synchronization task with SQL client. From Mysql to ADB, the historical data has been synchronized normally
- Applet sliding, clicking and switching simple UI
- ES6中的函数进阶学习
- Or in SQL, what scenarios will lead to full table scanning
- Interface test
- UnityWebRequest基础使用之下载文本、图片、AB包
猜你喜欢
Word自动生成目录的方法
Fiddler break point
Use of JSON extractor originals in JMeter
Memory ==c language 1
Postman interface test III
Flex flexible layout
Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
一大波开源小抄来袭
Bean 作⽤域和⽣命周期
request对象对请求体,请求头参数的解析
随机推荐
ORM模型--数据记录的创建操作,查询操作
2016 CCPC Hangzhou Onsite
嵌入式背景知识-芯片
Flex flexible layout
Google Colab装载Google Drive(Google Colab中使用Google Drive)
VS Code指定扩展安装位置
ORM--数据库增删改查操作逻辑
STM32产品介绍
14th test
Huffman encoded compressed file
Application of C # XML
每周推荐短视频:L2级有哪些我们日常中经常会用到的功能?
C socke server, client, UDP
Advanced function learning in ES6
Word自动生成目录的方法
Applet sliding, clicking and switching simple UI
Horizontal split of database
Video based full link Intelligent Cloud? This article explains in detail what Alibaba cloud video cloud "intelligent media production" is
Using keras in tensorflow to build convolutional neural network
Pytest learning - dayone