- Home /
Question by
Requiem99 · Mar 31, 2015 at 10:37 AM ·
c#androidcrashwww.texture
display www.texture from url causes crash in some devices
Hi! I need to download an image from a url and display it in a UI.Image component as sprite. I wrote the code below, but it doesn't work in my Samsung Galaxy Tab 3, while it works with a Samsung Galaxy S4 phone. So, why with some devices it works and with others the application crash?
public void Start () {
StartCoroutine(RealLoadImage());
}
private IEnumerator RealLoadImage () {
string url = "http://www.MY_URL_IMAGE...";
WWW imageURLWWW = new WWW(url);
yield return imageURLWWW;
if(imageURLWWW.texture != null)
{
Sprite sprite = new Sprite();
sprite = Sprite.Create(imageURLWWW.texture, new Rect(0, 0, imageURLWWW.texture.width, imageURLWWW.texture.height), Vector2.zero);
GetComponent<UnityEngine.UI.Image>().sprite = sprite;
}
yield return null;
}
This script is attached to the UI.Image
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613191749im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Random android crashes 1 Answer
Game crashes after sleep mode in Android 0 Answers
WebClient on Android 0 Answers
App crashes after splash screen with Google Play Services for AR update (after April 11th 2020) 2 Answers