{
buffer2 = new byte[stream.Length];
stream.Read(buffer2, 0, buffer2.Length);
}
stream.Length失败
解决方案
1、用unity自带的www类
2、https://bbs.csdn.net/topics/360163784
byte[] result;
byte[] buffer = new byte[4096];
WebRequest wr = WebRequest.Create(someUrl);
using(WebResponse response = wr.GetResponse())
{
using(Stream responseStream = response.GetResponseStream())
{
using(MemoryStream memoryStream = new MemoryStream())
{
int count = 0;
do
{
count = responseStream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, count);
} while(count != 0);
result = memoryStream.ToArray();
}
}
}