GUI's documentation lacks of examples

Hi guys,

I’m quite sad to know that GUI’s documentation lacks of basic examples like vertically/horizontally centering objects inside a group, align text inside a label, make bold text, make elements act like resizable etc…

I am desperatly looking for a way to center GUI’s inside a GUI.BeginGroup(), and make them occupy 100% of the free space inside that group. I can’t find it anywhere.

Thanks!

with GUI.BeginGroup() you already pass a rect of this group, so you know it’s size

to draw a GUI within group to it’s 100$ size, just draw in rect (0,0,groupXsize,groupYsize)

to draw a GUI centered inside group, just draw in rect (groupXsize * 0.5 - contentXsize * 0.5, groupYsize * 0.5 - contentYsize * 0.5, contentXsize, contentYsize);

if your content is dynamic and you don’t know it’s size, use GUILayout or this

GUILayout example

void OnGUI()
{
	GUILayout.BeginArea(new Rect(100, 100, Screen.width - 200, Screen.height - 200));
	GUILayout.BeginHorizontal();
	GUILayout.FlexibleSpace();
	GUILayout.BeginVertical();
	GUILayout.FlexibleSpace();
	GUILayout.Box("me is dynamic text
and me placed in the center
don't use GUI layout if you can 8)");
	GUILayout.FlexibleSpace();
	GUILayout.EndVertical();
	GUILayout.FlexibleSpace();
	GUILayout.EndHorizontal();
	GUILayout.EndArea();
}