Photon Unity Networking, Hiding a room permanently.
Options
Hi, I am trying to make a 4 player multiplayer board game using Photon Unity Networking. I am using the same code as the photon vikings demo for creating and joining rooms. What I want to do to hide a room permanently when the game has started. The game starts once the Number of players in the room equals the max players. So I don't want any one to join after that even if a player leaves the room. So I have added a custom property to the room with key called GameStarted and I have set it's value to true when the playerCount in the room equals the max players. And I have added the following code to the room joining script. But it doesn't seem to work.
The custom property is only added when the game has started so I have checked if the room contains the specific key in it's custom properties and I only want to display the room if it doesn't have the key GameStarted. The list updates if I add of remove a room. But is not updated when the custom property is added. Am I doing something wrong or is there a better way of doing this. I would really appreciate the help. Thanks.
foreach (RoomInfo game in PhotonNetwork.GetRoomList())
{
if (!game.customProperties.ContainsKey("GameStarted")
{
GUILayout.BeginHorizontal();
GUILayout.Label(game.name + " " + game.playerCount + "/" + game.maxPlayers);
if (GUILayout.Button("JOIN"))
{
PhotonNetwork.JoinRoom(game.name);
}
GUILayout.EndHorizontal();
}
}
The custom property is only added when the game has started so I have checked if the room contains the specific key in it's custom properties and I only want to display the room if it doesn't have the key GameStarted. The list updates if I add of remove a room. But is not updated when the custom property is added. Am I doing something wrong or is there a better way of doing this. I would really appreciate the help. Thanks.
0
Comments
-
To hide a room just add
PhotonNetwork.room.visible = false;
1 -
oh ok. thanks it helped alot0