CustomRoomPropertiesForLobby is not working
Options
AT1LLA
✭
Here is how i create my room:
room.CustomProperties.Count 0
Am I doing something wrong? Thanks.
public void CreateRoom(){ LobbyOptions = new string[2]; LobbyOptions[0] = MapIndex; LobbyOptions[1] = GameModeIndex; RoomOptions roomOptions = new RoomOptions(); roomOptions.IsVisible = true; roomOptions.IsOpen = true; roomOptions.MaxPlayers = (byte)MaxPlayersIndex; roomOptions.CustomRoomPropertiesForLobby = LobbyOptions; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default); }Here is how I get my rooms:
public override void OnReceivedRoomListUpdate() { Debug.Log("GET ROOMS: " + PhotonNetwork.GetRoomList().Length); foreach (RoomJoiner roomButton in rooms) { Destroy(roomButton.gameObject); } rooms.Clear(); int i = 0; foreach (RoomInfo room in PhotonNetwork.GetRoomList()) { if (!room.open) continue; GameObject roomButton = Instantiate<GameObject>(roomButtonPrefab); roomButton.GetComponent<RoomJoiner>().RoomName = room.name; string info = room.name.Trim() + " (" + room.playerCount + "/" + room.maxPlayers + ")"; Debug.Log(info); Debug.Log("room.CustomProperties.Count " + room.CustomProperties.Count); roomButton.GetComponentInChildren<Text>().text = info; rooms.Add(roomButton.GetComponent<RoomJoiner>()); roomButton.transform.SetParent(ServerListPanel, false); roomButton.transform.position.Set(0, i * 120, 0); } }CONSOLE
room.CustomProperties.Count 0
Am I doing something wrong? Thanks.
1
Best Answer
-
Did you try merging my suggestion with your code?
Room properties are key/values where keys are strings.
Something like this:public void CreateRoom(){ LobbyOptions = new string[2]; LobbyOptions[0] = MapIndexKey; LobbyOptions[1] = GameModeIndexKey; ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() { { MapIndexKey, mapIndexValue }, { GameModeIndexKey, gameModeIndexValue } }; RoomOptions roomOptions = new RoomOptions(); roomOptions.IsVisible = true; roomOptions.IsOpen = true; roomOptions.MaxPlayers = (byte)MaxPlayersIndex; roomOptions.CustomRoomPropertiesForLobby = LobbyOptions; roomOptions.CustomRoomProperties = customProperties; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default); }
1
Answers
-
Hi @AT1LLA,
Thank you for choosing Photon!
Please try setting values to those custom room properties when creating the room.ExitGames.Client.Photon.Hashtable roomSettings = new ExitGames.Client.Photon.Hashtable() { { MapIndex, mapIndex }, { GameModeIndex, gameModeIndex } }; roomOptions.CustomRoomProperties = roomSettings;
1 -
Hi @JohnTube ,
Sorry I didn't explained myself. I want to create a lobby. I will have some string variables like GameMode and Map. I want to show them in lobby. I tried your script but it didnt work. I tried
roomOptions.CustomRoomProperties = new string[] { "1", "2", "3" };
just to test but it alse didnt work. I think my problem is hov i get the values.
I do
Debug.Log("room.CustomProperties.Count " + room.CustomProperties.Count);
as the sctipt i posted. Thank you for your answer.0 -
Did you try merging my suggestion with your code?
Room properties are key/values where keys are strings.
Something like this:public void CreateRoom(){ LobbyOptions = new string[2]; LobbyOptions[0] = MapIndexKey; LobbyOptions[1] = GameModeIndexKey; ExitGames.Client.Photon.Hashtable customProperties = new ExitGames.Client.Photon.Hashtable() { { MapIndexKey, mapIndexValue }, { GameModeIndexKey, gameModeIndexValue } }; RoomOptions roomOptions = new RoomOptions(); roomOptions.IsVisible = true; roomOptions.IsOpen = true; roomOptions.MaxPlayers = (byte)MaxPlayersIndex; roomOptions.CustomRoomPropertiesForLobby = LobbyOptions; roomOptions.CustomRoomProperties = customProperties; PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default); }
1 -
Oh, I did it thank you0