- Home /
How to make a GUI Label always in the center
I have a gui label that shows one of my int variables, but when it gets to the points where it adds another digit, it is no longer centered. Is there anyway to have it always be centered without writing everything out?
Answer by SkaredCreations · Dec 14, 2014 at 04:31 PM
If the label is the only element in the row, choose a fixed width size for it and assign a GUIStyle that has Alignment=MiddleCenter and then (if you're not using GUILayout) write it at X position: (Screen.width-yourFixedWidth)/2
PS: if it's displayed inside a GUILayout Area or a GUI Box then replace "Screen.width" with your area/box width
Your answer
Follow this Question
Related Questions
GUI Destroy Label? 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
GUI Scripting button controls 1 Answer
Center GUI.Label similar to GUIText? 2 Answers