Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void LoadPNG(string filePath, Button btn)
- {
- Texture2D tex = null;
- byte[] fileData;
- if (File.Exists(filePath))
- {
- fileData = File.ReadAllBytes(filePath);
- tex = new Texture2D(2, 2);
- tex.Apply();
- Sprite img = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f);
- btn.image.sprite = img;
- //tex.LoadImage(fileData); //..this will auto-resize the texture dimensions.
- }
- else
- Debug.LogError("Could't load thumbnail image from streaming assets.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement