IEnumerator loadImage()
{
WWW www = new WWW("http://u3dchina.com/template/singcere_dw/common/images/logo.png");
yield return www;
txt2d = new Texture2D(4, 4, TextureFormat.DXT1, false);
www.LoadImageIntoTexture(txt2d);//Resources.LoadAssetAtPath("http://u3dchina.com/template/singcere_dw/common/images/logo.png", typeof(Texture)) as Texture;
GameObject.Find("Game1BG").GetComponent().mainTexture = txt2d;
}
unity动态加载图片
最新推荐文章于 2025-09-11 15:45:54 发布
本文介绍了一种在Unity中使用IEnumerator协程加载网络图片的方法,并将其转换为Texture2D对象的过程。通过创建一个WWW对象来从指定URL下载图片,然后使用LoadImageIntoTexture方法将下载的图片加载到Texture2D中,并最终应用到GameObject的游戏背景上。
3131

被折叠的 条评论
为什么被折叠?



