- Home /
set Strings parts in different colors
Hi!
Is there a way to set guiText's or GUI.Label's String parts in different colors?
For example
#pragma strict
@script RequireComponent(GUIText)
@HideInInspector
var str: String=Hi, Folks!; //need to access globally, but no need to show in Inspector
private var guiT: GUIText;
private var color1: Color=Color.red;
private var color2: Color=Color.white;
function Start()
{
// str's first two simbols are Red and Remaining ones are white
guiT=guiText;
guiT.text=str;
}
Thanks in advance!
SCape.
im trying to avoid this one :D if there wont be any solution then ill use multiple GUITexts...
$$anonymous$$aybe there is a way to set an char array and set color to each of char?
PS. i havent used an char array in UnityScript - is it even possible?
you could always check the RICH TEXT button and use
<color:Cyan>
this only works for GUIText, GUI.labels you will need to code a parser/string splitter.
Answer by almo · Jul 20, 2011 at 05:23 PM
Use multiple GUITexts. Graham is right.
it looks like there is no other way - thanks anyways!
Your answer
Follow this Question
Related Questions
Input string to Color conversion 1 Answer
convert string to color 3 Answers
Material doesn't have a color property '_Color' 4 Answers
Need some help with understanding Extensions 0 Answers
Gui list and color 0 Answers