Text Alignment

is it possible to center align the output of this statement?
I keep running into a syntax error of some sort. Any help would be greatly appreciated!

GUI.Label (Rect (45, 45, 100, 40), GUI.tooltip);

You can create a GUIStyle by simply declaring a variable at the top of your script which when the script (component) is selected, you can go to the Properties panel and modify the style that way. Unity3d Docs GUIStyle

var myStyle:GUIStyle;

You can also create a GUISkin and modify the values through the skin as well. Unity3d Docs GUISkin

OR … you can change the alignment on the individual reference of your label (or button, etc …) directly through the code below. Be aware though, that once you change the Alignment property, it stays changed for EVERY Other label (or button, etc …) reference. The way to change just one item would be to follow the code below: (change style, create GUI element, change style back to original state)

    GUI.skin.label.alignment = TextAnchor.MiddleLeft;
    GUI.Label(Rect(10,10,200,400),"My Text");
    GUI.skin.label.alignment = TextAnchor.MiddleCenter;   

Below are the possible Text Alignment options. If you want to change the alignment for a button instead of a label, just change the word “label” for whatever default style it is that you want to change.

    GUI.skin.label.alignment = TextAnchor.MiddleLeft;
    GUI.skin.label.alignment = TextAnchor.MiddleRight;
    GUI.skin.label.alignment = TextAnchor.MiddleCenter;
    GUI.skin.label.alignment = TextAnchor.LowerCenter
    GUI.skin.label.alignment = TextAnchor.LowerLeft
    GUI.skin.label.alignment = TextAnchor.LowerRight
    GUI.skin.label.alignment = TextAnchor.UpperCenter
    GUI.skin.label.alignment = TextAnchor.UpperLeft
    GUI.skin.label.alignment = TextAnchor.UpperRight

Alignment can be controlled using GUIStyles:

 var tooltipStyle : GUIStyle;

 function OnGUI ()
 {
   GUI.Label(Rect(0, 0, 100, 100), GUI.tooltip, tooltipStyle);
 }

You can then create a GUIStyle, drag it into the inspector, and change its alignment property.