- Home /
 
Need help displaying score (JavaScript)
I have created a basically finished game that can be played by the blind (there is no graphics). However, as I have been testing it, I have realized that I would like to make this game more enjoyable to those who aren't blind and add a few visual stuff. What I want to do is in the top left (or right, doesn't matter) corner of the screen I want the current score to be displayed. (currently all that happens is the score is read out as audio every so often).
Since this is my first unity project and I haven't used any of the GUI and visual aspects of unity, I don't know how to do this. After some research I think I need to do something like this. What I have currently is
 function score() {
     distanceScore += (Variables.actualFps + 88) / 5280;    //distanceScore is my score
     GUI.Box(new Rect (10,10,100,20),distanceScore); //this is what I assumed would display the score
 }
 
 InvokeRepeating("score",1,1); //this is how the score is refreshed and displayed.
     
 
 
              Answer by markedagain · Jun 05, 2014 at 07:45 PM
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnGUI.html
the OnGUI function is where u want to do all this.
This. Any time you are drawing GUI on screen from a script it has to be called in the OnGui() function.
Your answer