image.source image unity code example
Example 1: unity image
using UnityEngine.UI
public Image image;
public Sprite mySprite;
public void ChangeImage ()
{
image.sprite = mySprite;
}
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; }
Example 3: unity change the source image or image
public Image test;
public Sprite example;
void Start()
{
test.sprite = example;
}