- Home /
Make the text alignment to be on left
Hi, I am new at Unity and I am trying to have the text alignment to be on left. But how could I do that?
What I have tried is like the image below:
Here is the code:
GUIContent boxText = new GUIContent("This is an example on how does the text on the box is align\nMy Name is");
void OnGUI()
{
Rect boxGUI = GUILayoutUtility.GetRect(boxText, "Box");
GUI.Box(boxGUI, boxText);
}
Anyone know how to make the text to be aligned to the left side?
Thank you.
Comment
Best Answer
Answer by maddFrogg · Apr 22, 2014 at 09:18 AM
Write this in OnGUI method
fontStyle = new GUIStyle( GUI.skin.label );
fontStyle.alignment = TextAnchor.MiddleLeft;
Previously you need to declare the fontStyle variable (GUIStyle)
You need to specify in your boxText that you use the fontStyle style, by parameter when creating the GUIContent.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Runs fine in editor, crash on switch platform to iOS. 0 Answers
How to Move an object after it was reproduced by spawn 0 Answers
Mathf.pingpong 4 Answers