There’s something fundamental about styles that I think I am missing. I am creating a style within a script. I clone it from the default label style. Then I make it bold and green. But the GUI.Label does not obey my styling!
private GUIStyle myLabelStyle;
private void Start ()
{
myLabelStyle = null;
}
private void OnGUI ()
{
if (myLabelStyle == null) // initialize here
{
myLabelStyle = new GUIStyle(GUI.skin.label);
myLabelStyle.fontStyle = FontStyle.Bold;
myLabelStyle.normal.textColor = Color.green;
}
GUI.Window(123, myRect, drawWindowContent, "Window Title");
}
private void drawWindowContent (int windowId)
{
GUI.Label(new Rect(5,5,80,80), "SomeText", myLabelStyle);
}
There’s no inspector use involved here. I want to do this solely within code! What am I missing? The label is simply ignoring my styling.