A quick question, if I want to change the source image of an “Image” component through a script, how would I go about that? I am trying to access the source image property but I can’t figure out how.
I think the easiest method would be to declare public variables and input your image and sprite directly into the inspector:
public Image imageToChange;
public Sprite newImage;
Then when you want to change it:
imageToChange.sprite = newImage;
edit: don’t forget to include the namespace of course
using UnityEngine.UI;
2 Likes
You sir or madam are my hero, thanks a ton!
1 Like