当前位置:网站首页>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);
}
}
}
边栏推荐
- Integer inversion
- Why are social portals rarely provided in real estate o2o applications?
- STM32产品介绍
- Postman interface test VI
- Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
- Win10安装VS2015
- 嵌入式背景知识-芯片
- Garbage disposal method based on the separation of smart city and storage and living digital home mode
- [learning notes - Li Hongyi] Gan (generation of confrontation network) full series (I)
- CentOS installs JDK1.8 and mysql5 and 8 (the same command 58 in the second installation mode is common, opening access rights and changing passwords)
猜你喜欢
Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
A wave of open source notebooks is coming
Postman interface test I
ORM model -- creation and query of data records
Basic use of JMeter to proficiency (I) creation and testing of the first task thread from installation
fiddler-AutoResponder
AI moves from perception to intelligent cognition
Delete a record in the table in pl/sql by mistake, and the recovery method
Official media attention! The list of top 100 domestic digital collection platforms was released, and the industry accelerated the healthy development of compliance
Postman interface test VI
随机推荐
Mongodb creates an implicit database as an exercise
虚数j的物理意义
【学习笔记-李宏毅】GAN(生成对抗网络)全系列(一)
一文讲解单片机、ARM、MUC、DSP、FPGA、嵌入式错综复杂的关系
Postman interface test V
2016 CCPC Hangzhou Onsite
一大波开源小抄来袭
ES6中的函數進階學習
ORM model -- associated fields, abstract model classes
The landing practice of ByteDance kitex in SEMA e-commerce scene
2020ccpc Weihai J - Steins; Game (SG function, linear basis)
Fiddler simulates the interface test
[untitled]
Check the example of where the initialization is when C initializes the program
Main (argc, *argv[]) details
Please ask me a question. I started a synchronization task with SQL client. From Mysql to ADB, the historical data has been synchronized normally
ORM -- database addition, deletion, modification and query operation logic
ORM--数据库增删改查操作逻辑
Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
为什么安装mysql时starting service报错?(操作系统-windows)