UnityWebRequest可用于请求网络上的图像或请求本地图像。
除了GetTexture之外,还有ab包的下载等。
using System.Collections; using system.collections.generic; 用户单元引擎; using UnityEngine.Networking; using UnityEngine.UI; publicclassloadsp : mono behaviour { publicimageimage _ main; 专用语音((开始坐标) Donwoladpic ) ); } ienumeratordonwoladpic ((string URL=' http://API.map.Baidu.com/images/weather/day /纯真枕头. png '; //string path=' e :/screen shot/caidan.png '; using (unitywebrequestrequest=unitywebrequesttexture.get texture (URL ) ) yieldreturnrequest.send webrequest ); texture 2d texture=(request.downloadhandlerasdownloadhandlertexture ).texture; spritesprite=sprite.create (texture,newrect ) 0,0,texture.width,texture.height ),Vector2.zero ); Image_Main.sprite=sprite; }}(1)支持的其他加载API
)2) ab包常用API。