Answer the question
In order to leave comments, you need to log in
Why doesn't the Sprite change?
I'm trying to change the sprite for image. The code seems to be correct, the sprite names change in the log, but the corresponding image is not displayed in the image.
private int number;
private Image TileImage;
private Sprite tileSprite;
private void Awake()
{
TileImage = transform.Find("TileImage").GetComponent<Image>();
}
void ApplyStyleFromHolder(int index)
{
tileSprite = Resources.Load<Sprite>(TileStyleHolder.Instance.TileStyles[index].Image);
TileImage.sprite = tileSprite;
Debug.Log(TileStyleHolder.Instance.TileStyles[index].Image);
}
Answer the question
In order to leave comments, you need to log in
Stanislav Korolevskiy, I wrote to you above that there should be a path to the file in the Recources folder
Read the documentation https://docs.unity3d.com/ScriptReference/Resources...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question