using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
using System.IO;
using System.Collections.Generic;
using UnityEngine.UI;
public class Text01 : MonoBehaviour
{
// Use this for initialization
void Start()
{
string path1 = @"file:///C:\Users\ji.liu\Documents\text01\Assets\Resources\3368.png"; //需要替换上去的资源路径
StartCoroutine(test(path1));
}
// Update is called once per frame
void Update()
{
}
public IEnumerator test(string path1)
{
//此处注意资源类型,范例中是控件Rawimage
RawImage oldimg = GameObject.Find("Canvas/oldimg").GetComponent<RawImage>();
//在C#中,需要用到yield的话,必须建立在IEnumerator类中执行。
WWW www = new WWW(path1);
//定义www为WWW类型并且等于所下载下来的WWW中内容。
yield return www;
//返回所下载的www的值
oldimg.texture = www.texture;
}
}