Getting int.ToString() displaying in UI Text
Hello,
I have a game where on the end screen the camera pans to a point then the score the player received is displayed at the top of the screen. The UI text displaying the score should read "Total Score: ##" but the number isn't displayed. Usually the problem when people post this is they forget to add .ToString() to the end of the integer, but I have done that. It just displays "Total Score:".
void FixedUpdate () {
if (cam_rb.position.z > zPos) {
cam_rb.AddForce (new Vector3 (0f, 0f, -5f));
} else {
cam_rb.isKinematic = true;
Debug.Log ("Score : " + score.ToString());
Debug.Log (score.ToString().GetType());
scoreDisp.text = "Total Score: " + score.ToString();
}
}
I added the Debug.Logs to make sure the game actually knows they score and score.ToString() is actually returning a string. The console shows that score is correct and it is a string so I am confused as to why the score.ToString() value is not appearing in the UI text but "Total Score: " still is. Any help would be appreciated.
I put the whole class in pastebin if that helps for reference. https://pastebin.com/szYiRJYp
Thanks, admiralmattbar
Are you sure the Text
component is simply large enough to display the score?
Your answer
Follow this Question
Related Questions
Number string to .text returning 0 0 Answers
Why is this List only showing one int? 0 Answers
BCE0022: Cannot convert 'String' to 'int' 0 Answers
Why is my listdisplaying that an item was removed? 0 Answers
how to connect my Health to my UI 1 Answer