当前位置:网站首页>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);
}
}
}
边栏推荐
- web3.0系列之分布式存储IPFS
- The request object parses the request body and request header parameters
- Wallys/IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL CONCURRENT
- 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)
- Writing file types generated by C language
- LeetCode 练习——113. 路径总和 II
- Natapp intranet penetration
- A wave of open source notebooks is coming
- Google colab loads Google drive (Google drive is used in Google colab)
- 运用tensorflow中的keras搭建卷积神经网络
猜你喜欢
ISP、IAP、ICP、JTAG、SWD的编程特点
The request object parses the request body and request header parameters
Pytest learning - dayone
Applet popup half angle mask layer
Fiddler simulates the interface test
Internship log - day04
Postman interface test VI
[original] what is the core of programmer team management?
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
LeetCode 练习——113. 路径总和 II
随机推荐
[original] what is the core of programmer team management?
终于可以一行代码也不用改了!ShardingSphere 原生驱动问世
The Himalaya web version will pop up after each pause. It is recommended to download the client solution
A wave of open source notebooks is coming
2016 CCPC Hangzhou Onsite
Using keras in tensorflow to build convolutional neural network
【ORM框架】
ORM -- grouping query, aggregation query, query set queryset object properties
Integer inversion
The landing practice of ByteDance kitex in SEMA e-commerce scene
ES类和对象、原型
China's first electronic audio category "Yamano electronic audio" digital collection is on sale!
Pit using BigDecimal
Flinkcdc failed to collect Oracle in the snapshot stage. How do you adjust this?
网上可以开炒股账户吗安全吗
Main (argc, *argv[]) details
14th test
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
Fiddler simulates the interface test
Hcip first day notes sorting