Commit 8da46df5 authored by mercury233's avatar mercury233

update pic.LoadImage

parent 587fe386
Pipeline #24674 passed with stages
in 309 minutes and 44 seconds
......@@ -747,13 +747,7 @@ public static class UIHelper
public static async Task<Texture2D> GetTexture2DAsync(string path)
{
var pic = new Texture2D(0, 0);
// Unity < 2021.2
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true);
var data = new byte[stream.Length];
await stream.ReadAsync(data, 0, (int) stream.Length);
pic.LoadImage(data);
// Unity >= 2021.2
// pic.LoadImage(await File.ReadAllBytesAsync(path));
pic.LoadImage(await File.ReadAllBytesAsync(path));
return pic;
}
......@@ -764,6 +758,7 @@ public static class UIHelper
ZipEntry entry = zip[file];
entry.Extract(stream);
//await Task.Run(() => { entry.Extract(stream); });
//并不能这样写,这个zip库好像不支持多线程
pic.LoadImage(stream.ToArray());
return pic;
}
......
......@@ -13,3 +13,4 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60
m_DefaultFrameRate: 60
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment