How to change a score
So I have made a Canvas with a text object in it which is supposed to display a score. I have made a script but I don't know how to reference it (like:
public GameObject AmmoUi;
public AmmoUi;
)
Answer by NerdClown · Sep 13, 2016 at 11:53 AM
public AmmoUI myAmmoUI;
Try that. Then you should be able to drag the game object with the AmmoUI script on it onto this in the inspector.
Gonna need some more info.
You have one script called AmmoUI. Do you have any more scripts. I assumed that there would be two, but I can't be sure.
If you only have one, you should put something like
public Text$$anonymous$$esh text$$anonymous$$esh; //drag this over in editor
public void Start()
{
SetScoreText(42);
}
public void SetScoreText(int newScore)
{
this.text$$anonymous$$esh.text = "Score "+newScore;
}
Your answer
Follow this Question
Related Questions
Control ScrollView with arrow keys? 3 Answers
How can I extend an UI Component and change it's default values when added on editor? 0 Answers
UI buttons sometimes does not detect touch 0 Answers
TiltShift Error 0 Answers
Scaling font size in Unity 5.0 0 Answers