0
I need that when a button is clicked, if the answer is correct the image (a bush) change (to a cow in front of the bush).
public class mudaSprite : MonoBehaviour {
public InputField dgt;
public Text txt;
public Sprite arbusto;
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
public void setget(){
if (dgt.text.ToLower().Equals("cinza")) {
if (spriteRenderer.sprite == null) {
spriteRenderer.sprite = Resources.Load<Sprite>("vacarbustoC");
}
ChangeTheDamnSprite ();
txt.text = "";
}
else {
txt.text="Tente Novamente!";
}
}
void ChangeTheDamnSprite(){
if (spriteRenderer.sprite == arbusto) {
spriteRenderer.sprite = Resources.Load<Sprite>("vacarbustoC");
} else {
spriteRenderer.sprite = arbusto;
}
}
pleaaase!!