Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DownloadImage()
- {
- using (var webClient = new WebClient())
- {
- webClient.DownloadDataCompleted += WebClient_DownloadDataCompleted;
- var imageBytes = webClient.DownloadDataTaskAsync(imageURL);
- downloadStarted = true;
- }
- }
- void WebClient_DownloadDataCompleted(object sender, System.Net.DownloadDataCompletedEventArgs e)
- {
- Debug.Log(sender.ToString());
- var imageBytes = e.Result;
- if (imageBytes != null && imageBytes.Length > 0)
- {
- var texture = new Texture2D(2, 2);
- texture.LoadImage(imageBytes);
- Rect rec = new Rect(0, 0, texture.width, texture.height);
- var spriteToUse = Sprite.Create(texture, rec, new Vector2(0.5f, 0.5f), 100);
- }
- }
Add Comment
Please, Sign In to add comment