I want to display the number of points and the amount of life of the player using the class GUI.Label . Part of this code looks like this:
void onGUI() { GUI.Label (new Rect (10, 10, 60, 20), "Score: " + player.score.ToString()); GUI.Label (new Rect (10, 30, 60, 20), "Score: " + player.lives.ToString()); }
But after the launch of the project these labels are not. Also, I tried to create a new project and copy the code that is specified in the official certificate. There is also nothing shown. Any ideas?
Unity3D 5.2.1f1
https://drive.google.com/file/d/0By40bSw4WlDGNi1TT2hFdThnNWM/view?usp=sharing
Addition:
Even if you put this code from the official certificate with multi-colored buttons into the new project, there is nothing after the launch:
void OnGUI() { GUI.color = Color.yellow; GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); GUI.Box(new Rect(10, 50, 50, 50), "A BOX"); GUI.Button(new Rect(10, 110, 70, 30), "A button"); }
Addition:
In general, Paul's comment helped me out. It was necessary to add a script to the camera. But the fun is that apparently in previous versions of Unity this was not necessary. Therefore, most theoretical courses contain this onGUI method code in those scripts that are responsible, for example, for the player, and the script could be located on a completely different object.
PS Moderators, how to make a comment the right answer?