using System.Collections; using system.collections.generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; publicclassdownloadimagefromserver : mono behaviour { void start ()//异步加载start coroutine (download image ) ); } void update (ienumeratordownloadimage ) ) unity engine.net working.unitywebrequesttexture.gww yield red if (www.isnetworkerror|| www.is http error ) { debug.log } www.error }; } else { texture2dmytexture=(downloadhandlertexture ) www.downloadHandler ).texture; spritecreatesprite=sprite.create (my texture,newrect ) 0,0,myTexture.width,myTexture.height,newvector2) 0 }}具体过程类似于以下链接
用于Unity的WWW类,从服务器加载图像
另外,Unity官网上有指向这一部分的链接
从HTTP服务器获取纹理(GET )
介绍UnityWebRequest的大人物
长江后浪推前浪,UnityWebRequest代替WWW
构建本地IIS服务器并将下载的内容保存到Unity
Unity使用UnityWebRequest从服务器下载文件