- Home /
GUI Label does not appear on screen.
I am currently trying to make a timer appear on screen by using the GUI Label but it does not appear and there arent any errors that I know of.I tried changing the values from 10 to 300 to 5000 and negative bu still does not appear.
GUI.Label(Rect(10,10,100,30),"Time:" +gameTime);
Answer by Piflik · Aug 29, 2012 at 06:14 PM
Where did you put this code?
GUI stuff should be in OnGUI().
Example:
function OnGUI() {
GUI.Label(Rect(10,10,100,30),"Time:" +gameTime);
}
I have a similar problem. I display a GUI Button. When clicked the label should appear. Button is displayed, Label not.
$$anonymous$$e too... in 2017 (Unity 5.3.5) It appears EditorGUILayout.LabelField() works better.
Answer by commawht · Nov 19, 2012 at 08:13 AM
aand the problem i had was "OnGUI" i had written "onGUI" - lower case first letter instead of upper case. stupid i know .. but it took me 15 mins to find out the pbm
Can confirm, this was exactly my mistake. Thanks for the tip.
Answer by Tyche10 · Apr 13, 2017 at 03:37 PM
Since I cannot comment, I will reply: I had the same problem. With me it was caused by the scale slider above the game view in the editor not being set to 1x
Answer by MaxRCG · Sep 27, 2017 at 06:45 AM
@Piflik i dont understand the problem here, it should display an asterisk in the centre as an aiming rectile, but it doesnt
private Camera _camera; void Start () { _camera = GetComponent ();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
void OnGUI() {
int size = 12;
float posX = _camera.pixelWidth/2 - size/4;
float posY = _camera.pixelWidth/2 - size/2;
GUI.Label (new Rect (posX, posY, size, size), "*");
You use "_camera.pixelWidth" two times. The second one should be _camera.pixelHeight.
Your answer
Follow this Question
Related Questions
GUI.label overlapping text 1 Answer
Dynamic Resizing of tooltip to match content? 1 Answer
(GUI.Label) Line spacing issue with wordwrap 0 Answers
Making a text box appear after a certain gameObject is destroyed 0 Answers
GUI Destroy Label? 3 Answers