1
\$\begingroup\$

I am using Photon for networking in my project. I am creating a room with PhotonNetwork.CreateRoom(). I pass in the room name as well as a set of room options where the room options just specify the number of players as well as a set of CustomRoomProperties. These CustomRoomProperties do not show up for other players when they try to join the room. The CustomRoomProperties hashtable is completely empty even though the room options sent in with the room creation are populated with them. Shouldn't the CustomRoomProperties persist when the room is created so that the values can be used for when others try to join the room? I essentially want to be able to make sure the room that the person is attempting to join has a matching custom room property value.

Below is an example of how I create room options and assign them to the room I create:

var options = new RoomOptions() { MaxPlayers = gameController.MaxPlayers };
options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
options.CustomRoomProperties.Add("myTestKey", "myTestValue");
PhotonNetwork.CreateRoom("roomName", roomOptions:options);
\$\endgroup\$
2
  • \$\begingroup\$ How do you retrieve? \$\endgroup\$
    – shingo
    Commented Jan 18, 2022 at 5:44
  • \$\begingroup\$ @shingo The room list is populated by the OnRoomListUpdate() function. I then look up the room by name to find the corresponding room. But once I grab that, the room doesn't have the custom properties that the host set. \$\endgroup\$
    – sabo
    Commented Jan 18, 2022 at 14:52

1 Answer 1

0
\$\begingroup\$

It turns out that the roomOptions.customRoomPropertiesForLobby property needs to contain the key for the custom property in order for it to be viewed from the lobby. So I just needed to add the line below when creating the RoomOptions and it allowed me to view that property from the other clients' perspective:

options.customRoomPropertiesForLobby = new string[1] { "myTestKey" };

So my code is as follows in the end:

var options = new RoomOptions() { MaxPlayers = gameController.MaxPlayers };
options.customRoomPropertiesForLobby = new string[1] { "myTestKey" };
options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
options.CustomRoomProperties.Add("myTestKey", "myTestValue");
PhotonNetwork.CreateRoom("roomName", roomOptions:options);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .