I want to put a server browser so the players can see the servers and join it, does any one know how to do it?
There is no server browser in the traditional way for Photon. The host is always Photon or one machine in the Photon Cloud. What you list are rooms where players actually play.
If you want that, have a look at the “Worker Demo” in the PUN package. Start multiple clients and make sure some of them create rooms (otherwise the list will be empty, of course).
And: In PUN v1.60, make sure to check “Auto Join Lobby” in the PhotonServerSettings as described here.
Make sure the autoJoinLobby is checked in the PhotonServerSettings. It always comes disabled!
public bool IsConnected;
public string roomName;
IsConnected = false;
roomName = "room01";
void OnGUI() {
if (IsConnected) {
GUILayout.BeginArea (new Rect (Screen.width / 2 - 250, Screen.height / 2 - 250, 500, 500));
roomName = GUILayout.TextField (roomName);
if (GUILayout.Button ("Create")) {
PhotonNetwork.JoinOrCreateRoom (roomName, null, null);
}
foreach (RoomInfo game in PhotonNetwork.GetRoomList()) {
if (GUILayout.Button (game.name + " " + game.playerCount + "/" + game.maxPlayers)) {
PhotonNetwork.JoinOrCreateRoom (game.name, null, null);
}
}
GUILayout.EndArea ();
}