WWW类废除,Unity提供了更加快捷的获取方式 ,如下:
IEnumerator GetAssetBundle()
{
//AB包路径
string bundlePath = Application.streamingAssetsPath + “/textrue”;
//直接使用UnityWebRequestAssetBundle获得AB包
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(bundlePath);
yield return www.SendWebRequest();
//最终获得
AssetBundle ab= DownloadHandlerAssetBundle.GetContent(www);
}
eg:2
///
/// 加载非预制对象
///
/// 本地路径or远端地址
/// 操作且显示的对象
/// 欲加载资源的名称
///
IEnumerator LoadNoObjAsset(string URL,GameObject showObj,string assetName)
{
//直接使用UnityWebRequestAssetBundle获得AB包
using (UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(URL))
{
yield return www.SendWebRequest();
//最终获得
AssetBundle ab = DownloadHandlerAssetBundle.GetContent(www);
if (ab != null)
{
showObj.GetComponent().material.mainTexture = ab.LoadAsset(assetName);
//卸载资源(只卸载AB包本身)
ab.Unload(false);
}
else Debug.Log(GetType() + “下载的AB包为空!” +“错误信息”+www.error); } }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算