change image x unity code example
Example 1: how to change a image with code unity
// Change From GameOject
public GameObject GameObjectWithImage;
public Sprite ImageYouWant;
GameObjectWithImage.GetComponent<Image>().sprite = ImageYouWant
// Change From Image
public Image Image;
public Sprite ImageYouWant;
Image.sprite = ImageYouWant
Example 2: unity image
//Make sure you are using UnityEngine.UI
using UnityEngine.UI
//We can assign this image in the inspector
public Image image;
//Also assign this in the inspector
public Sprite mySprite;
public void ChangeImage ()
{
image.sprite = mySprite;
}