I created a GUI Label with C#. How to change color and size?

GUI.Label(new Rect(700, 100, 240, 240), “” + m_PlayerName);

First you need a GUIStyle that allows rich text and you pass it to the label. Then you can use rich text tags to style it however you want.

//Color tags <color=red></color>
//Size tag <size=32></size>
GUIStyle richTextStyle = new GUIStyle();
richTextStyle.richText = true;
GUI.Label(new Rect(700,100,240,240), "<color=red><size=32>" + m_PlayerName + "</size></color>", richTextStyle);

Here’s the documentation on rich text tags. You can also use them for the UI system and even on console logs.


Note: I declared and instantiated the GUIStyle right above the call to GUI.Label just for the example, but it would be preferable if you did it outside of OnGUI so you don’t keep recreating it every time the Label is drawn (you could do have it as a field, initialize it inside OnEnable,then use it).