How to get CustomRoomPropertiesForLobby and CustomRoomProperties ?
attolee
✭
Click a button to create room, pass roomOps to PhotonNetwork.CreateRoom,
public void Confirm() { RoomOptions roomOpts = new RoomOptions(); roomOpts.MaxPlayers = 2; roomOpts.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable(); roomOpts.CustomRoomProperties.Add("GameTime", "120"); roomOpts.CustomRoomProperties.Add("NumLife", "10"); roomOpts.CustomRoomPropertiesForLobby = new string[2] { "GameTime", "NumLife"}; // create a room and join it PhotonNetwork.CreateRoom("attp's battle field", roomOpts, null); }I want to show GameTime and NumLife in lobby, so try access those properties in callback OnReceivedRoomListUpdate,
public override void OnReceivedRoomListUpdate() { // get room list info RoomInfo[] roomInfos = PhotonNetwork.GetRoomList(); RoomListTableViewController roomListCon = GameObject.Find("RoomListTableViewController").GetComponent<RoomListTableViewController>(); roomListCon.m_numRows = roomInfos.Length; if (roomInfos.Length > 0) { foreach (RoomInfo roomInfo in roomInfos) { roomListCon.roomNames.Add(roomInfo.name); // I try access GameTime and NumLife here } } }
0
Comments
-
Hi @attolee,
The room custom properties visible to the lobby are available in the RoomInfo class:roomInfo.customProperties
:
So you should first add the properties to the lobby ones:roomOpts.CustomRoomPropertiesForLobby = new string[2] { "GameTime", "NumLife"};
Then you can do something like this:string GameTime = roomInfo.customProperties["GameTime"]; string NumLife = roomInfo.customProperties["NumLife"];
1