Well i got a text next to my coins sprite and i want to change the score to be the same as my double “coins” but i have no idea how to do that i searched in forums about it but couldnt find the answer i need this is my code.
It is attached to my sprite changer.Can i create another script to attach it to the text UI or i need to add the code in this script ?
using UnityEngine;
using System.Collections;
public class SpriteChanger : MonoBehaviour {
public Sprite sprite1;
public Sprite sprite2;
private SpriteRenderer spriteRenderer;
static public double coins = 0.00;
void Start ()
{
spriteRenderer = GetComponent<SpriteRenderer>();
spriteRenderer.sprite = sprite1;
}
void Update ()
{
if (coins >= 30) {
ChangeTheDamnSprite ();
coins = 0;
}
}
void ChangeTheDamnSprite ()
{
if (spriteRenderer.sprite == sprite1)
spriteRenderer.sprite = sprite2;
}
void UpdateScore (){
}
}