S
S
Stanislav Korolevskiy2019-08-07 11:15:05
Unity
Stanislav Korolevskiy, 2019-08-07 11:15:05

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

1 answer(s)
S
Stanislav Korolevskiy, 2019-08-07
@korolevsky_s

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 question

Ask a Question

731 491 924 answers to any question