Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to change the colour of Handles.Label?

Discussion in 'Immediate Mode GUI (IMGUI)' started by petey, Nov 3, 2021.

  1. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
    Hi all,

    I'm using Handles.Label in OnDrawGizmos, and I was wondering, how do you change the colour of a label?
    I see in the docs you can set a GUIStlye but I have no idea how to set the colour.
    Can someone point me in the right direction there?

    Thanks!
    Pete
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    Code (CSharp):
    1. GUIStyle style = new GUIStyle();
    2. style.normal.textColor = Color.red;
    3. Handles.Label(position, text, style);
     
  3. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
    adamgolden likes this.
  4. ExNinja

    ExNinja

    Joined:
    Dec 4, 2013
    Posts:
    30
    You can also use a GUIStyle with richText=true and then set the color using a rich text tag like:
    "<color=red>Now this text is red</color>"
     
    mantisjoe, Ghosthowl and adamgolden like this.
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,817
  6. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    760
    Thanks!!!
     
    adamgolden likes this.