GUILayout is currently driving me nuts!
GUILayout.BeginArea(new Rect(Screen.width/1.5F+100, 120, 300, 500));
GUILayout.BeginVertical(tables);
foreach (KeyValuePair<string, string[]> Entry in Tables)
{
GUILayout.Space(Entry.Value.Length * 20);
}
GUILayout.EndArea();
GUILayout.EndVertical();
Whenever a user joins the table I space it out vertically by the number of people in the table, hence the “Entry.Value.Length * 20”.
Now, I want to draw the list of users to that table within that space…
then do so 
use guilayout for the horizontal one inside the loop and have an inner loop within that horizontal block to draw the row
Thanks!!
I have been thinking that it needs to be a new area, for the rows:
Within the interation scheme in my first post:
GUILayout.BeginArea(new Rect(Screen.width-220, 135, 210, 500));
GUILayout.BeginVertical(s);
foreach (string users in Entry.Value)
{
GUILayout.BeginHorizontal(s);
GUILayout.Label(users.Split(' ')[0], s);
GUILayout.Space(85);
GUILayout.Label(users.Split(' ')[1] + " " + users.Split(' ')[2].Substring(0,2), s);
GUILayout.EndHorizontal();
}
}
GUILayout.EndArea();
GUILayout.EndVertical();
The first table works, ‘n’ users can join the first table and the other tables will spread out evently. Sadly, that is not the case for users joined to the others after the first.
The only way that I have it slightly working is with seperate iteration schemes…Even then its off by a noticable amount.
can you please post the whole code?
also there is an error with above code btw: you first open area, then vertical but closing you aren’t doing it the right way in consequence your console in the editor actually should be flodded by errors when you enter play mode as you must close it the reverse order of opening (its a stack)
Thanks!! I think the definite problem was forgetting that the control groups (GUILayout) was a stack. Writting this code really reminds of of OpenGL…
Its not quite completely the way I like it, but multiple tables owrk for multiple users joined to them =)))
Hi,
It looks like I’ve found my old post…I am still having trouble, what I’d like to acheive is:
Table #1
-user1
-user2
Table #2
-user3
-user4
Where the Table’s are the Keys in Dictionary<string,List> and the users are values to that dictionary. Programmatically, we have:
void Display() {
int numOfTables = 1;
GUILayout.BeginArea(new Rect(0,50,500,500)); //layout for keys
foreach (KeyValuePair<string, List<string>> Entry in Tables)
{
if (Entry.Value.Length > 0) {
GUILayout.Label("Table#" + numOfTables.ToString(), s);
GUILayout.BeginArea(new Rect(0, 60, 500,500)); //name layout
foreach (string users in Entry.Value)
{
GUILayout.Label(users, s);
}
GUILayout.EndArea(); //User Name Area
}
numOfTables++;
}
GUILayout.EndArea(); //Table Name Area
}
The above does not currently display any users within the table names. I know I am wrong, I just do not know where and I have tried rearranging the GUILayout for the users.