i want to have a button (and labels) that have multiple colors.
i suppose there's no way to format the string that i pass as a parameter to the button command
GUI.Button(GetBuysellButtonArea(), "Buy XXX gold for YYY money)");
where the string is in white and XXX is in RED and YYY is in BLUE ?
any suggestions?
my idea is to create an empty button with several labels, each using a different style on top of the button.
but i seems like a bad idea.
esepcially since i'm considering i want the text to be centered in th button area, and i have no idea how to do that by combining labels, even if i ue GUILayout.
Oded
i'm thinking i woudl like something like HTML where you can write echo "buy <FONT Color=RED>XXX</font> gold for <FONT color=BLUE>YYY</font> money";
You cannot, as far as I know, color different words in a single label with different colors, and I honestly can't think of a way to do it, short of basically writing your own Label function (which would be a major pain). Have you considered using textures instead of labels? You can make a texture of the words you want to use (in one color, of the words that will always be the same), and then you can position the GUI.Labels in a different color with the number values that you want to fill in.
i decided to give this idea up :( i need string concatenation of dynamic variables, with different length (i.e. 1 gold vs 100000 gold) and i want it to be nice and centered. i tried some methods nothing worked good.
While it is technically possible to do what you want to do, it would be a pain in the ass to code it so it looked nice. Sorry you had to give up, nonetheless.
Any news about that ? I'm having the same problem, and I'd very like to find a solution ! There could be a hint here, but it's seems quite complicated, plus it doesn't compile on my unity :/
i'm thinking i woudl like something like HTML where you can write echo "buy <FONT Color=RED>XXX</font> gold for <FONT color=BLUE>YYY</font> money";
– anon23375740