Quantcast
Channel: Answers for "How Do I Center A GUI Label?"
Browsing all 9 articles
Browse latest View live

Answer by Jesus_Freak

hey there again! here's the code to do that: var windowWidth : int = 200; var windowHeight : int = 200; /*var here from your other script should be Str. doesn't have to be in this script though. that's...

View Article


Answer by Eric5h5

You need a GUIStyle that has a centered alignment. You can do this programmatically by getting an existing style and setting the alignment:function OnGUI () { var centeredStyle =...

View Article


Answer by langalang

Another way is to set the alignment to "Upper Center" in the GUIStyle. Set your label to be anchored to the x=0 and height you want, then make sure your label width is set to the screen width. Eg...

View Article

Answer by squishy312

This seems to work for me in C#, should be similar in Javascript. :) GUI.Box (new Rect ((Screen.width)/2 -(Screen.width)/8,(Screen.height)/2-(Screen.height)/8,(Screen.width)/4,(Screen.height)/4),...

View Article

Answer by Jesus_Freak

hey there again! here's the code to do that: var windowWidth : int = 200; var windowHeight : int = 200; /*var here from your other script should be Str. doesn't have to be in this script though. that's...

View Article


Answer by Eric5h5

You need a GUIStyle that has a centered alignment. You can do this programmatically by getting an existing style and setting the alignment:function OnGUI () { var centeredStyle =...

View Article

Answer by langalang

Another way is to set the alignment to "Upper Center" in the GUIStyle. Set your label to be anchored to the x=0 and height you want, then make sure your label width is set to the screen width. Eg...

View Article

Answer by squishy312

This seems to work for me in C#, should be similar in Javascript. :) GUI.Box (new Rect ((Screen.width)/2 -(Screen.width)/8,(Screen.height)/2-(Screen.height)/8,(Screen.width)/4,(Screen.height)/4),...

View Article


Answer by shikekaka

Thanks, everyone! I spent half a day on this, and I realize it was because of the ** Rect** not centering, not because of the **GUI Label**. ---------- A quick fix would be to move the starting point...

View Article

Browsing all 9 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>