unity change ui image sprite code example
Example 1: unity ui change sprite
// TO change the sprite of an UI image, se below
GameObject.GetComponent<Image>().sprite = sprite;
Example 2: image.sprite unity
Image1.sprite =new Sprite;
// TO change the sprite of an UI image, se below
GameObject.GetComponent<Image>().sprite = sprite;
Image1.sprite =new Sprite;