Script to change a Sprite to another
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;
}
}
Comment
Answer by Cuttlas-U · Oct 26, 2017 at 06:01 AM
hi; the problem can be any where from scripts to editors; u have to debug these kind of problems step by step i cant help u here like this;
u may log the "Lives" or the times that function "UpdateHearts" is calling or check the editor to see if another image is not showing in front or etc ...
Your answer
Follow this Question
Related Questions
Stuck inside of Composite Collider when using Platform Effector 2D 2 Answers
how I change this C code for 2D 1 Answer
Rotate towards mouse pointer 1 Answer
Sprite not moving properly? 0 Answers