unity Texture2d Base64 相互转换
//Base64ToTexture2D
public Texture2D Base64ToTexture2D(string Base64STR)
{
Texture2D pic = new Texture2D(190, 190, TextureFormat.RGBA32, false);
byte[] data = System.Convert.FromBase64String(Base64STR);
pic.LoadImage(data);
return pic;
}
//Texture2DToBase
public String Texture2DToBase64(Texture2D t2d)
{
byte[] bytesArr = t2d.EncodeToJPG();
string strbaser64 = Convert.ToBase64String(bytesArr);
return strbaser64;
}
好使