Get Custom room properties in Lobby (PUN2)

I want to get the properties of a room when I'm in lobby. I'm sure that the properties are setted to show on lobby with adding a string to it. But, at the moment to get this properties instantiating with the RoomInfo class, it seems to be empty.
This is the code I use to create a new room:

 if (IF.text.Length > 0 && IF.text.Length <= 20)
            int PlayerAmount = Int32.Parse(PlayerField.text);
            RoomOptions roompos = new RoomOptions()
                IsVisible = true, IsOpen = true, MaxPlayers = (byte)PlayerAmount
            roompos.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
            roompos.CustomRoomProperties.Add("OnlineArray", BehaviourModel.OnlineArray);
            roompos.CustomRoomProperties.Add("PlayerLock", ScoreScript.PlayerLock);
            roompos.CustomRoomProperties.Add("PlayerDic", WinPanelS.PlayerDic);
            if (!PrivacyB.Privacy)
                if (PI.text.Length > 5)
                    Password = PI.text;
                    roompos.CustomRoomProperties.Add("Password", Password);
                    HavePass = true;

                roompos.CustomRoomProperties.Add("Password", null);
            string[] Property = new string[] { "Password" };
            roompos.CustomRoomPropertiesForLobby = Property;
            PhotonNetwork.CreateRoom(IF.text, roompos);

And this is the code to get them:

RoomName = T.text;
       Has.Add("Password", CreateRoomS.Password);
       R = new RoomInfo(RoomName,);
       if (R.CustomProperties["Password"] == null)
           Password = (string)R.CustomProperties["Password"];
           Protector.GetComponent<Animator>().SetBool("Show", true);
           LockPanel.GetComponent<Animator>().SetBool("Show", true);
           IsByB = true;

Just noticed this a bit late.

Be aware that the "Password" field will be "plain text" and not really secure. Much less, if you send it to the lobby as property. This is probably not what your players will be aware of.

Overall, we would like to avoid using the room listing as much as possible. If a game has a password, it should maybe not even be listed. You can put rooms with password into their own lobby. Maybe players should know room name and password. If they may know the room name, then let users enter both and you won't have to fetch the room list in the first place.

I have a similar problem.... I'm creating a room using the method:

LoadBalancingClient.OpCreateRoom(EnterRoomParams params);

this is my code:

 public void CreateRoomWithOptions(string name, RoomOptions options)
        EnterRoomParams enterRoomParams = new EnterRoomParams();

        RoomOptions roomOptions = options;
        roomOptions.IsVisible = true;
        roomOptions.IsOpen = true;
        enterRoomParams.Lobby = typedLobby;
        enterRoomParams.RoomName = name;
        enterRoomParams.RoomOptions = roomOptions;



then I try to retrieve the information sent as part of RoomOptions:

public void UpdateRoomList(List<RoomInfo> roomList, GameRoomMode mode)
        int indexDataDisplayed = 0;
        for (int x = 0; x < roomList.Count; x++)
           string mGameMode= roomList[x].CustomProperties[NetworkManager.roomGameMode].ToString();
//more code....

but CustomProperties is always null... I can confirm that the first room that I get in the list is in fact the one that I have created in another client (at least the name of the room is the same)

Am I doing something wrong?


If I access this property "networkManager.Client.CurrentRoom.CustomProperties" within the client that has created the room, the CustomProperties are displayed correctly.



you need to elect custom properties to be visible in the lobby, else they are considered private ( and saves bandwidth at the same time)

can you check this post:

and this doc:



1 Like