Why photon room properties not found in lobby?
Options
The player can create a room with certain properties that once created I set them and for lobby so that I can then display them in the lobby.
Function to create room:
public void OnCreateRoomButtonClicked() { RoomOptions roomOptions = new RoomOptions(); roomOptions.IsOpen = true; roomOptions.IsVisible = true; string roomName; string gameMap; if (gameMode.Equals("CarMeeting")) { gameMap = carMeetingModeMaps[mapIndex].sceneName; roomName = roomNameCarMeetingModeInputField.text; roomOptions.MaxPlayers = 4; } else { gameMap = racingModeMaps[mapIndex].sceneName; roomName = roomNameRacingModeInputField.text; roomOptions.MaxPlayers = 2; } if (!CheckIfRoomAlreadyExists(roomName)) { StartCoroutine(EShowWarning()); } else { roomOptions.CustomRoomProperties = new Hashtable(); roomOptions.CustomRoomProperties.Add("GameMap", gameMap); roomOptions.CustomRoomProperties.Add("GameMode", gameMode); roomOptions.CustomRoomProperties.Add("RaceMode", raceMode); string[] customLobbyProperties = new string[4]; customLobbyProperties[0] = "GameMap"; customLobbyProperties[1] = "GameMode"; customLobbyProperties[2] = "RaceMode"; roomOptions.CustomRoomPropertiesForLobby = customLobbyProperties; PhotonNetwork.CreateRoom(roomName, roomOptions, null, null); } }
Function display rooms in lobby:
public override void OnRoomListUpdate(List<RoomInfo> roomInfo) { Debug.Log("Rooms found " + roomInfo.Count); bool roomFound = false; foreach (RoomInfo room in roomInfo) { if (room.RemovedFromList) { int index = roomUIs.FindIndex(x => x.roomNameString.Equals(room.Name)); if (index != -1) { Destroy(roomUIs[index].gameObject); roomUIs.RemoveAt(index); } } else { CMRoomUI cacheRoomUI = roomUIs.Find(x => x.roomNameString.Equals(room.Name)); if (cacheRoomUI != null) { if (room.CustomProperties["GameMode"].ToString().Equals("CarMeeting")) cacheRoomUI.Check(room.Name, (room.PlayerCount + "/" + room.MaxPlayers).ToString(), room.CustomProperties["GameMap"].ToString(), room.CustomProperties["GameMode"].ToString()); else cacheRoomUI.Check(room.Name, (room.PlayerCount + "/" + room.MaxPlayers).ToString(), room.CustomProperties["GameMap"].ToString(), room.CustomProperties["GameMode"].ToString() , room.CustomProperties["RacingMode"].ToString()); } else { if (room.IsOpen) { CMRoomUI roomUI = Instantiate(roomUIPrefab.gameObject, roomUIParent).GetComponent<CMRoomUI>(); roomUIs.Add(roomUI); if (room.CustomProperties["GameMode"].ToString().Equals("CarMeeting")) roomUI.Check(room.Name, (room.PlayerCount + "/" + room.MaxPlayers).ToString(), room.CustomProperties["GameMap"].ToString(), room.CustomProperties["GameMode"].ToString()); else cacheRoomUI.Check(room.Name, (room.PlayerCount + "/" + room.MaxPlayers).ToString(), room.CustomProperties["GameMap"].ToString(), room.CustomProperties["GameMode"].ToString() , room.CustomProperties["RaceMode"].ToString()); } } } } if (roomUIs.Count > 0) roomFound = true; noRoomTextObj.SetActive(!roomFound); }
After I create a room if another player connects to the looby, I display the cameras visible with those properties, but the property "RaceMode" does not exist.
0