0

I have a button UI game object. That doesn't have an image from the start. I fetch a image from the server and then set it as button image. Here is the code:

WWW w = new WWW (newUrl);
yield return w;
Adbutton.GetComponent<Image>().sprite =  Sprite.Create(w.texture,new Rect(0, 0, 100, 100),new Vector2(0,0));

The button does change color but image is not set. Help me out!

Adrian Krupa
  • 1,877
  • 1
  • 15
  • 24
Sameer Hussain
  • 2,421
  • 8
  • 23
  • 41

1 Answers1

0

Can you use a "RawImage" rather than "Image" component on the button? There are some (slight) performance disadvantages, but it should be assignable directly, without the need to create an intermediate Sprite.

Will Gee
  • 168
  • 7