Reputation:
The Unity manual does not give examples of the params
in the following particular version of GUILayout.Label
(or is it somewhere else that I cannot seem to find?)
public static void Label(Texture image, GUIStyle style, params GUILayoutOption[] options);
So, I am wondering how to change the font size of the following code that I am dealing with:
I have a normal OnGUI()
in an Editor file:
GUILayout.BeginHorizontal( displayStyle1 );
GUILayout.Label( "Has title?" );
if ( hasTitle )
{
if( GUILayout.Button( "yes", GUILayout.Width(40) ) )
{
hasTitle = true;
}
GUILayout.EndHorizontal();
}
and I have my own MyOnGUI()
in an Executor file:
if( fieldInput.HasTitle )
{
GUILayout.BeginHorizontal( displayStyle1 );
GUILayout.Label( fieldInput.Title, displayStyle1 );
GUILayout.EndHorizontal();
}
Once you press yes and enter the title in the Editor, what you get after the Executor runs needs to be in bigger font, so I thought I should modify this line:
GUILayout.Label( fieldInput.Title, displayStyle1 );
therefore, I need to see an example of how to specify a bigger font as 3rd parameter...
Is this possible? Is it the right way of directly changing font size without modifying the set styles?
Upvotes: 1
Views: 3129
Reputation: 16287
var style= GUI.skin.GetStyle("label");
style.fontSize = 24; // whatever you set
GUILayout.Label( fieldInput.Title, style);
Upvotes: 1