FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read); ? ? ? ? byte[] bytes = new byte[fileStream.Length]; ? ? ? ? fileStream.Read(bytes, 0, (int)fileStream.Length); ? ? ? ? fileStream.Close(); ? ? ? ? fileStream.Dispose(); ? ? ? ? fileStream = null; ? ? ? ? int width = 300; ? ? ? ? int height = 372; ? ? ? ? Texture2D texture = new Texture2D(width, height); ? ? ? ? texture.LoadImage(bytes); ? ? ? ? Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); ? ? ? ? image.sprite = sprite;
|