第一种
IEnumerator _discount(ConfigData configData)
{
string url = configData.res;
FileInfo fileInfo = new FileInfo(url);
WWW www = new WWW("file://" + fileInfo.FullName);
DisPar.texture = www.texture;
yield return www;
}
第二种
public static Texture2D ByteToTex2d(byte[] bytes, int w = 100, int h = 100)
{
Texture2D tex = new Texture2D(w, h);
tex.LoadImage(bytes);
return tex;
}
public static Texture2D GetFileTex(string filePath, int w = 100, int h = 100)
{
if (!File.Exists(filePath))
return null;
byte[] imgData = File.ReadAllBytes(filePath);
return ByteToTex2d(imgData);
}