- Home /
Question by
a_elsayed2010 · Sep 18, 2011 at 01:14 PM ·
guiguitext
GUI Text and null pointer exception
Hi All,
I'm new using unity3d, and I'm creating simple game and I want to show the score of the player, I have insert GUIText to the bottom of the screen
and I have created HUDController and create Public variable of type GUIText, then drag this class to one of the game objects and assign my GUIText to the public variable
and try to set the text in the update method but I got a null pointer exception
If I have did anything wrong please let me know
Thanks in Advance
Comment
Answer by Rydrako · Sep 18, 2011 at 04:28 PM
What I would do is have a script attached to the GUIText simmilar to this
function Update () {
//Here the text will always ='s to the score
guiText.text = PlayerScoreScript.score;
}
in your script that controls the score make sure to make a static var that is the player score. Hope this helps!
Your answer
