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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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,732
    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,349
    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,732
    adamgolden likes this.
  4. ExNinja

    ExNinja

    Joined:
    Dec 4, 2013
    Posts:
    27
    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>"
     
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,732