- Home /
GUI content horizontal alignment
Hi !
I'm using GUILayout for my GUI content, and I'd like to set horizontal alignment centered...
But my content is made of pic, buttons and vertical slider, no text !
How can I set the horizontal alignement ?
My code looks like this :
GUILayout.BeginArea(new Rect(...)); GUILayout.BeginVertical();
GUILayout.Box(mypic);
myslidervalue = GUILayout.Slider(myslidervalue, ...);
if(GUILayout.Button("blabla"){...}
GUILayout.EndVertical(); GUILayout.EndArea();
I've tried to set a GUIStyle in the BeginArea or BeginVertical with TextAnchor.MiddleCenter but it doesn't seem to set it for any other content than text...
Thanks for helping me !
please make your code show as code in the post, mark the code and press the 10101010 button in the text formatting bar :)
Answer by Krysalgir · Jun 06, 2011 at 01:11 PM
Thanks for the rotation tip, but I found my own answer !
I've found the GUILayout.FlexibleSpace(), mixed with a Begin/EndHorizontal(), this makes auto center, like CSS.
Answer by Pflegeleichtt · Jun 06, 2011 at 09:28 AM
you can rotate your gui, maybe this helps :
GUIUtility.RotateAroundPivot (rotationnew, pivotPoint);
when you want to seperate these from the other gui you can use a GUIMatrix :
var oldMatrix = GUI.matrix;
//---
//Rotatecode
//---
GUI.matrix = oldMatrix;
Your answer
Follow this Question
Related Questions
GUILayout element alignment issue 0 Answers
Help with GUILayout and tooltip(C#) 1 Answer
For Loop GUILayout.Label Problems 1 Answer
Is there a method for getting Scrollview to work in a GUILayout Window? 2 Answers
Aligning Cards in Hand Deck 1 Answer