GUI.Label issue

Hello everyone, I’ve been “playing” with unity for a month now, just for hobbie, so much fun! I’m making my first app and I have this odd annoying thing happening: when I display a text, the text is duplicated twice in the game with two different font sizes like in the picture below.

I just want the big font to be displayed.
Here’s my code for the GUI

    void OnGUI()
    {
        if(isRunning == true)
        {
            GUI.Label(new Rect(50, 25, 100, 30), "Player Score: " + playerScore, style);
            GUI.Label(new Rect(750, 25, 100, 30), "Special Bullets: " + SpecialBullet, style);
            GUI.Label(new Rect(50, 100, 100, 30), "Record: " + Record, style);

        }
        else
        {
            Debug.Log(NewRecord);
            if (NewRecord == true)
            {
                GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 15, 100, 30), "Game Over. \n You made a new record of: " + (playerScore), styleDead);
                PlayerPrefs.SetFloat("Record", Record);
            }
            else
            {
                GUI.Label(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 15, 100, 30), "Game Over. \n Your score was: " + (playerScore), styleDead);
            }
        }
    }

Here’s the style that I use for the GUISkin

Everything is set to default.
I can’t find any mistake anywhere, little help? :slight_smile: Thank you very much to everyone!

Could be the script is on multiple GameObjects in the same scene or you have multiple cameras with a GUILayer component attached to them.

1 Like

Silly me! Yeah the script was both on the camera and on another game object! Great hint! Thank you very much! :slight_smile:

A good way to find that quickly is

Debug.Log("where am I?", gameObject);

Clicking on that in the console will highlight the GameObject where the log came from.

1 Like