Hi,
I’m trying to change the sprite of a UI Image. I want it to be a random choice between 9 images, named Meme1.png till Meme9.png.
They’re all in the /Assets/Resources/Sprites/Server folder.
My code is:
private void ChangeServerSprite() {
int rndSprite = Random.Range(1, 9);
string spriteToLoad = "/Sprites/Server/Meme" + rndSprite;
Sprite sprite = Resources.Load(spriteToLoad, typeof(Sprite)) as Sprite;
server.GetComponent<Image>().overrideSprite = sprite;
}
The method is being called, the random number works just fine (tested with breakpoints), but the Sprite called sprite is always null.
Any help would be MUCH appreciated!

