GUI.Label not showing up
I have a script to show a timer, but the GUI.Label isn't showing up. I know the script is working, because the Debug.Logs are giving me feedback. Anyone tell what the problem is? Here is my script
'using UnityEngine; using System.Collections;
public class Timer : MonoBehaviour {
public float timeRemaining = 10f;
GUIStyle guiStyle = new GUIStyle();
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
timeRemaining -= Time.deltaTime;
if(timeRemaining <= 0){
//Debug.Log("Time's up");
timeRemaining = 0;
}
}
void OnGUI(){
if(timeRemaining > 0){
Debug.Log("Test 1");
guiStyle.fontSize = 50;
guiStyle.normal.textColor = Color.black;
GUI.Label(new Rect(0, 0, 0, 0), "Time: " + (int)timeRemaining, guiStyle);
}else{
Debug.Log("Test 2");
guiStyle.fontSize = 50;
guiStyle.normal.textColor = Color.yellow;
GUI.Label(new Rect(0, 0, 0, 0), "Time's Up ", guiStyle);
}
}
}`
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612085814im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why is my GUI popup showing up for both host and client? 0 Answers
Duplicate GUI.Label Instances 1 Answer
Get Width/Height Of String Outside of OnGUI Method 1 Answer
Drawing onGUI Stuff over each other? 0 Answers
Scaling GUI with resolution 0 Answers