Hi,
i created a UI.Text object to display the number of gold colected in a clicker game, but it only displays the tet directly inputed into the text box.
this is the script that i used to try to display it.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Click : MonoBehaviour {
public int Gold = 0;
public int goldPerClick = 1;
public Text goldDisplay;
void start()
{
countGold();
}
void update()
{
countGold();
}
public void Button(){
Gold = Gold + goldPerClick;
}
void countGold()
{
goldDisplay.GetComponent<Text>().text = "Gold: " + Gold.ToString();
}
}
i tried using:
goldDisplay.text = "Gold: " + Gold.ToString();
goldDisplay.GetComponent().text = "Gold: " + Gold;
goldDisplay.GetComponent().text = "Gold: " + Gold;
the variable changes but the text isnt displayed.
can anyone help me?