I have created an editor window script to create an editor window. I have a Rect variable headerRect with the following properties:
headerRect.x = 0f;
headerRect.y = 0f;
headerRect.width = Screen.width;
headerRect.height = 50f;
GUI.DrawTexture(headerRect, headerRectTexture);
Here is the function that creates a label in the headerRect section.
private void DrawHeaderSection() // Draws the Header Section
{
GUILayout.BeginArea(headerRect);
EditorGUILayout.LabelField("CHARACTER EDITOR", guiSkin.GetStyle("Header"));
GUILayout.EndArea();
}
The GUISkin has a style called “Header” and it mentions that the alignment is MiddleCenter but still the alignment is not proper. Rather, it seems that the text is starting from the middle of the width. The following image will demonstrate the problem.
How do I properly align the label to the centre?