- Home /
Update Gui Text with Score
in the script below, it changes the guitext the next time the level is loaded, but can someone help me update the text when the score is updated.
here is the script
var Counter : int = 0;
function addscore () {
Counter++;
guiText.text = ""+Counter;
if (Counter > 100){
guiText.anchor = TextAnchor.UpperRight;
guiText.pixelOffset = Vector2 (100,351);
}
}
function endlevel (){
guiText.text = "0";
Counter = 0;
}
thanks in advance
ps, if there is a link to something that can help me can you post it please, thanks :)
Answer by Izzy4me · Nov 08, 2014 at 10:10 PM
I don't get it... Are you calling "addscore" function every time player scores a point and score isn't updated?
guiText.text = ""+Counter; and guiText.text = Counter.ToString(); should work the same
addScore isn't startLevel!
Of course you can write guiText.text = Counter.ToString(); in Update or OnGUI function, but your code should work too... Just please let us know where you will call your addscore funcion ;)
Your answer
Follow this Question
Related Questions
Make Gui Text only appear based on array 1 Answer
Loading a scene and keeping original score 3 Answers
facebook with unity problem 0 Answers
How to call a function in another script 1 Answer
GUIText update error 1 Answer