so basically what i am trying to achieve is a grid like server list. Kind of like “Halo: CE”:
In the Halo server list, the lenght of each part is even and clamped…
This is what I have so far. The problem is that if i make the name of something shorter or longer it pushes all of the other stuff down. Like this:
[26297-how+it+is.png|26297]
This is how I want it (I havent achieved the alignment, this one is photoshopped so you understand):
[26298-how+it+should+be.png|26298]
So, yeah, how would I fix this alignment issue?
(ps: Im using “GUILayout.BeginHorizontal” and such)
Thanks in advance.
Your current layout looks like you place all your rows (inner) in one vertical group (outer). That way you will have the same height for all cells in a row but it will adjust the cells in it’s width independently.
If you create the vertical groups (inner) first and place these groups in a horizontal group (outer) your cells would have the same width within their column but vary in height. Unfortunately there is no proper grid layout for mixed content afaik.
The Halo lobby seems to have a fixed height anyway so you would be good using the second layout if you want the same- vertical within horizontal.
A simple example (not testet)
float rowHeight = 50f;
GUILayout.BeginHorizontal();
{
GUILayout.BeginVertical();
{
GUILayout.Label("cell 0:0 - Long text should expand other cells within this col", GUILayout.Height(rowHeight));
GUILayout.Label("cell 0:1", GUILayout.Height(rowHeight));
}
GUILayout.EndVertical();
GUILayout.FlexibleSpace(); //take as much space as possible between the cols
GUILayout.BeginVertical();
{
GUILayout.Label("cell 1:0", GUILayout.Height(rowHeight));
GUILayout.Label("cell 1:1", GUILayout.Height(rowHeight));
}
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
{
GUILayout.Button("cell 2:0", GUILayout.Height(rowHeight));
GUILayout.Button("cell 2:1", GUILayout.Height(rowHeight));
}
GUILayout.EndVertical();
}
GUILayout.EndHorizontal();
You could also find the highest cell dynamically and adjust other cells.
use GUI instead of GUILayout