- Home /
MultiColor In 1 Label?
Hello Guyz i have 1 Label
GUILayout.Label(PlayerName + "Is" + "Dead");
i want It Multicolor (PlayerName > Red. "Is" > Green. "Dead" > Blue)
Without useing This Code :
GUI.color = Color.red;
GUILayout.Label(PlayerName)
GUI.color = Color.Green;
GUILayout.Label("Is")
GUI.color = Color.Blue;
GUILayout.Label("Dead")
Because i Need It In 1 Line Only
Answer by Bunny83 · Feb 08, 2013 at 02:54 PM
If you use Unity4, just use HTML tags:
http://forum.unity3d.com/threads/152443-Unity-4-styled-text-any-docs
Keep in mind that you have to use a style that has the richText property ticked.
edit
If you use Unity3x or earlier you have to use something like that:
GUILayout.BeginHorizontal();
GUI.color = Color.red;
GUILayout.Label(PlayerName)
GUI.color = Color.Green;
GUILayout.Label("Is")
GUI.color = Color.Blue;
GUILayout.Label("Dead")
GUILayout.EndHorizontal();
In some cases that's even more flexible since you can define a specific size for each part
-.- Thx but i said that i dont need it multi line .. i need multi color in 1 line.
using GUILayout.BeginHorizontal(); ... GUILayout.EndHorizontal(); as Bunny83 suggested should put it on a single line
i know , i'm already using BeginHorizontal but its make my message Like This :
PlayerName Is Dead not : PlayerName Is Dead
because my $$anonymous$$sg inside box [chat system]
Answer by umar43 · Feb 09, 2015 at 12:15 PM
you can use html colour codes to set multiple colours of a label. Example: "[FF0000]Red[0000FF]Blue"
Your answer
Follow this Question
Related Questions
Change Color For One Line? 1 Answer
How do you change the size and color of a GUI Label in C#? 4 Answers
Labels aren't colored properly 1 Answer
Color.white not so much white... 3 Answers
How do I make a colour editor UI? 1 Answer