x


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 !

more ▼

asked Jun 06 '11 at 09:16 AM

Krysalgir gravatar image

Krysalgir
16 2 2 2

please make your code show as code in the post, mark the code and press the 10101010 button in the text formatting bar :)

Jun 06 '11 at 09:18 AM Kacer
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jun 06 '11 at 01:11 PM

Krysalgir gravatar image

Krysalgir
16 2 2 2

(comments are locked)
10|3000 characters needed characters left

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;
more ▼

answered Jun 06 '11 at 09:28 AM

Pflegeleichtt gravatar image

Pflegeleichtt
4 6 7 11

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3812
x144
x29

asked: Jun 06 '11 at 09:16 AM

Seen: 2230 times

Last Updated: Jun 06 '11 at 01:11 PM