Question by
Marc_Keil · Mar 28, 2018 at 08:46 AM ·
spritespictureimage loader
Update a Sprite in Scene
Hey Guys,
i am trying to download some pictures from URL and show them in a Image. What i need to do now is to update the Image. That does not work and i dont know why.
string url = "https://docs.unity3d.com/uploads/Main/ShadowIntro.png";
string url1 = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
Image image;
List <Sprite> sprite_test = new List<Sprite>();
IEnumerator Start()
{
// Start a download of the given URL
using (WWW www = new WWW(url))
{
// Wait for download to complete
yield return www;
// assign texture
image = GetComponent<Image>();
image.sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0));
image.sprite.name = "Pic1";
sprite_test.Add(image.sprite);
}
using (WWW www = new WWW(url1))
{
// Wait for download to complete
yield return www;
// assign texture
image.sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0));
image.sprite.name = "Pic2";
sprite_test.Add(image.sprite);
}
}
// Update is called once per frame
void Update ()
{
foreach(Sprite sprite in sprite_test)
{
image.sprite = sprite;
}
}
It would be awesome if anybody can help me to figure that out.
Comment
Your answer

Follow this Question
Related Questions
Error when importing Image per script 0 Answers
Pixel of a Sprite under the MousePosition 1 Answer
Problems with the way my sprites look 2 Answers
Change sprite onTriggerEnter2D 0 Answers
Weird artifacts appear on my 2D sprites. 0 Answers