[code]csharpcode: /// <summary> /// 加载图片 /// </summary> private Sprite LoadTexture(string url){ using (Bitmap bitmap = new Bitmap(url)) { Bitmap bmp = new Bitmap(bitmap, 256, 256); bitmap.Dispose(); bmp.Save(Application.streamingAssetsPath + "/1.bmp", System.Drawing.Imaging.ImageFormat.Png); } //创建文件读取流 FileStream fileStream = new FileStream(Application.streamingAssetsPath + "/1.bmp", FileMode.Open, FileAccess.Read); //创建文件长度缓冲区 byte[] bytes = new byte[fileStream.Length]; //读取文件 fileStream.Read(bytes, 0, (int)fileStream.Length); //释放文件读取流 fileStream.Close(); //释放本机屏幕资源 fileStream.Dispose(); //创建Texture int width = 256; int height = 256; Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, true); texture.LoadImage(bytes); texture.Apply(); Debug.Log(texture.format); //创建Sprite Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); return sprite; }