[PUN] Server List GUI Help

Hi

I need to have a server list for my game but I do not know how to make one. I want to have the server list using the “GUI.___” something instead of GUILayout. But the current code that can be found in the demo files are in GUILayout so I have no idea how I can make one. If you know how I can make a server list, please tell me!

Here is the code that I am currently using as a placeholder if it helps.

foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList())
				{
					GUILayout.Label(roomInfo.name + " " + roomInfo.playerCount + "/" + roomInfo.maxPlayers);
					if (GUILayout.Button("Join Server"))
					{
						PhotonNetwork.JoinRoom(roomInfo.name);
					}
				}

Thanks

Really, you ned to think about the process to get the desired result. What do you have, and what do you want?

  • A list of rooms that are iterated through with a foreach loop.
  • For every room, display the name, player count, then a button to join, all in a single row.

untested pseudocode to demonstrate the process

int i = 0;

foreach ( RoomInfo roomInfo in PhotonNetwork.GetRoomList() )
{
	GUI.Box( new Rect( 20, 20 + (i * 30), 300, 25 ), roomInfo.name + " " + roomInfo.playerCount + "/" + roomInfo.maxPlayers );
    
	if ( GUI.Button( new Rect( 320, 20 + (i * 30), 100, 25 ), "Join Server") )
	{
		PhotonNetwork.JoinRoom(roomInfo.name);
	}
    
	i ++;
}