how to change image in unity c# code example
Example 1: how to change a image with code unity
public GameObject GameObjectWithImage;
public Sprite ImageYouWant;
GameObjectWithImage.GetComponent<Image>().sprite = ImageYouWant
public Image Image;
public Sprite ImageYouWant;
Image.sprite = ImageYouWant
Example 2: unity c# change image source
Image[] images = PlayerBarExample.GetComponentsInChildren<Image>(); Image face = images[0]; foreach (Image image in images) { if (image.gameObject.CompareTag("face")) face = image; }