About room custom properties

Options

I'm trying to show in the lobby the rooms list and providing the roominfo of each room, so far ive got the name, playercount, maxplayers and isopen. but when i try to make custom properties it just doesnt work

Rooms list updating -

public override void OnRoomListUpdate(List<RoomInfo> roomList)

   {

       UpdateRoomList(roomList);

   }

   public void UpdateRoomList(List<RoomInfo> list)

   {

       foreach (RoomJoinButton button in _roomJoinButtonsList)

       {

           Destroy(button.gameObject);

       }

       _roomJoinButtonsList.Clear();

       foreach (RoomInfo room in list)

       {

           RoomJoinButton newRoom = Instantiate(_roomJoinButton, _scrollViewRoomsTransform);

           newRoom.SetRoomSettings(room.Name, $"{room.PlayerCount} / {room.MaxPlayers}", (string)room.CustomProperties["g"], (string)room.CustomProperties["m"], room.IsOpen? _openRoomSprite : _lockedRoomSprite);

           _roomJoinButtonsList.Add(newRoom);

       }

   }

Room Creation -

public void CreateRoom()

   {

       if (_lobbynameInput.text.Length >= 1)

       {

           ExitGames.Client.Photon.Hashtable customProperties = new()

           {

               { "g" , _gameModes[_selectedGameMode] },

               { "m" , "Lobby"},

           };

           RoomOptions roomOptions = new()

           {

               IsOpen = _toggleRoomOpen.isOn,

               IsVisible = _toggleRoomVisible.isOn,

               MaxPlayers = (byte)_roomMaxPlayers.value,

               CustomRoomProperties = customProperties,

               CustomRoomPropertiesForLobby = new string[] { "g", "m" },

           };

           PhotonNetwork.CreateRoom(_lobbynameInput.text, roomOptions);

       }  

       else

       {

           _roomNameWarning.SetActive(true);

       }

   }

Instantiated prefab for the roominfo -

[SerializeField] private TextMeshProUGUI _roomNameText, _playerCountText, _gameModeText, _currentMapText;

   [SerializeField] private Image _isOpenImage;

   public void SetRoomSettings(string roomName, string playerCount, string gameMode, string currentMap, Sprite isOpenImage)

   {

       _roomNameText.text = roomName;

       _playerCountText.text = playerCount;

       _gameModeText.text = gameMode;

       _currentMapText.text = currentMap;

       _isOpenImage.sprite = isOpenImage;

   }


I've tried everything for over 2 hours including asking chatgpt and mish mashing random combinations.

I really hope the code is clear enough.

Thank you for the help if anyone read all of it 😀

Answers

  • Tobias
    Options

    Apparently, you defined which properties should be visible in the lobby. You also get the list of rooms from the lobby and show some.

    That looks all correct.

    At this point, I'd use VS debugger and break at the point where you access the RoomInfo. Check if the properties are provided. Alternatively, try ToStringFull() on the properties Hashtable (it's an extension to print the content).

    Sorry, I don't see an issue (yet).