您的位置:首页 > 理论基础 > 计算机网络

Unity动态更换外部Texturte和网络文件

2015-12-28 13:26 387 查看
桌面文件:

using UnityEngine;

using System.Collections;

public class WWWdownload : MonoBehaviour {

public string url = “file://C:\Users\admin\Desktop\新建文件夹\200711912230489_2.jpg”;

IEnumerator Start()
{
WWW www = new WWW(url);
yield return www;
GetComponent<Renderer>().material.mainTexture = www.texture;
}


void Update () {

}


}网络文件:

using UnityEngine;

using System.Collections;

public class WWWdownload : MonoBehaviour {

public string url = “http://image.baidu.com/i?tn=download&ipn=dwnl&word=download&ie=utf8&fr=result&url=http%3A%2F%2Fa2.att.hudong.com%2F04%2F58%2F300001054794129041580438110_950.jpg“;

IEnumerator Start()
{
WWW www = new WWW(url);
yield return www;
GetComponent<Renderer>().material.mainTexture = www.texture;
}


void Update () {

}


}如果想大规模替换网络端口文件,则需要建立服务器。如果要大规模替换本机文件,则需要建立相应架构的文件夹系统或者数据库。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: