我希望在我的场景中添加一个脚本组件的空游戏对象。我想要做的是当用户与这个游戏对象发生碰撞时,从远程服务器下载img文件并显示...
我对WWW统一课有一点了解,但我不是100%如何实现它来做我想要的,任何代码建议?
答案 0 :(得分:0)
试试这个。
IEnumerator LoadPictureAnimate (string url) {
WWW www = new WWW(url);
yield return www;
Texture2D texture2D = www.texture;
Rect textureRect = new Rect(0, 0, texture2D.width, texture2D.height);
GetComponent<SpriteRenderer>().sprite = Sprite.Create (texture2D, textureRect, new Vector2(0.5f, 0.5f));
}