Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Simple GUI Label bold text help

Discussion in 'Immediate Mode GUI (IMGUI)' started by Holynub, Nov 18, 2010.

  1. Holynub

    Holynub

    Joined:
    Nov 9, 2010
    Posts:
    60
    Hello all,

    I've been scouring the unity reference manuals and the forums for something simple. I have a string I'm calling to a GUI Label that creates a timer. All I want to do is have the font bolded. I'm not looking to change the font or size or anything. Just bold it out. I've seen things like using GUIText and GUIStyles or switching the font to a pre-bolded font. Is there a simpler way of doing this?

    Code (csharp):
    1.  
    2.     ClockTime = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
    3.    
    4.     GUI.Label(Rect(0,0,100,50),ClockTime);
    5.  
     
  2. Holynub

    Holynub

    Joined:
    Nov 9, 2010
    Posts:
    60
    PhotonPotatoDev likes this.
  3. PhotonPotatoDev

    PhotonPotatoDev

    Joined:
    Dec 20, 2020
    Posts:
    4
    GUIStyle insertVarNameHere = new GUIStyle();
    insertVarNameHere.fontStyle = FontStyle.Bold;

    //The underlined word "Bold" can be changed out to be "Italic" or "BoldAndItalic"
    //After this just make the label with insertVarNameHere as an argument like so:

    GUILayout.Label("Whatever You Want As Your Text Here", insertVarNameHere);

    This is just for anyone who sees this forum and needs help...
    Hope this helps!

    Unity GUI Style Docs: https://docs.unity3d.com/ScriptReference/GUIStyle.html
     
    zanouk likes this.