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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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,773
    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,516
    Code (CSharp):
    1. GUIStyle style = new GUIStyle();
    2. style.normal.textColor = Color.red;
    3. Handles.Label(position, text, style);
     
    Ghosthowl and boycey10802002 like this.
  3. petey

    petey

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

    ExNinja

    Joined:
    Dec 4, 2013
    Posts:
    29
    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>"
     
    Ghosthowl and adamgolden like this.
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,773