IO流代码:
void LoadByIO() { float time = Time.time; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); fs.Seek(0, SeekOrigin.Begin); byte[] bytes = new byte[fs.Length]; fs.Read(bytes, 0, (int)fs.Length); fs.Close(); fs.Dispose(); fs = null; Texture2D t = new Texture2D(1,1); t.LoadImage(bytes); img.texture = t; Debug.Log("IO读取图片用时:" + (Time.time-time)); }ponent<Image>();image.sprite = sprite;
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。