September 2010
Beginner
384 pages
8h 49m
English
We'll use the FlexibleSpace() method of the GUILayout class to center the grid on the screen, first vertically and then horizontally.
BuildGrid() function. GUILayout.FlexibleSpace() calls inside the GUILayout.BeginVertical() and GUILayout.EndVertical() calls, like so:function BuildGrid()
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
for(i=0; i<rows; i++)
{
// the rest of the code is in here, but we've removed it for the sake of simplicity
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
The game grid is now centered vertically on the screen. There's an equal amount of space above the grid as there is below it.
Read now
Unlock full access