This is part of my script, but it doesn’t work in gameplay when I call this method the hearts are still there without showing any change
void UpdateHearts()
{
if (data.Lives == 3)
{
ui.heart1.sprite = ui.fullHeart;
ui.heart2.sprite = ui.fullHeart;
ui.heart3.sprite = ui.fullHeart;
}
if (data.Lives==2)
{
ui.heart1.sprite = ui.emptyHeart;
}
if (data.Lives == 1)
{
ui.heart2.sprite = ui.emptyHeart;
ui.heart1.sprite = ui.emptyHeart;
}
}