- Home /
Trying to make a score script that shows the score through a GUIText object.
I'm very new to unity and C# but I'm trying to make a script that keeps track of the player's score and displays it through a GUIText object.
So far I have the GUIText object and I've set it as child of the main camera but it doesn't stay in the camera's view and I'm not sure why. In my score script I have score declared as a variable and in void update() I convert it to a string but I'm not sure how to display it in the GUIText object.
Does anybody know a good tutorial that could help me understand what I'm doing wrong?
Thanks in advance for any help and I'm sorry if this is a stupid question.
Don't know which video cover exactly what your asking, but watching all the vids here, with experiments in between will save you OODLES of time. http://unity3d.com/learn
if the GUIText is not view-able by the camera (check in 'game' view without running the game to see if it shows up in the right location) then maybe you haven't set the GUIText's transform right - it should be between 0 and 1 with 0.5 being the center of the screen. Any number less than 0 and more than one for its transform x and y will have it appearing offscreen...
Oh and PS, you can set the GUIText's variable "text" to change the text you see on it - so just get a reference to it at the top of your script, like public GUIText $$anonymous$$yGUIText; and then set in inspector - and you can do $$anonymous$$yGUIText.text = "$$anonymous$$y New Text " + 1; to change it to a different value.