How to get custom properties using RoomInfo in Photon Unity ?
I am using RoomOptions to create a room for a multiplayer game. I am setting custom properties like :
public void OnCreateButtonClick() { _customProperties = new Hashtable() { {CustomPropertyKeys.LosePointsPropertiesKey, pointsToLostValueRadioSystem.ToggleValue}, {CustomPropertyKeys.SoqqaPropertiesKey, sliderValue.CostValue} };
var roomOptions = new RoomOptions
{
MaxPlayers = MaxPlayers,
PlayerTtl = playerTimeToLive,
IsVisible = !isClosedRoom,
CustomRoomProperties = _customProperties
};
networkService.CreateGame(roomOptions);
}
The problem arises when I want to get custom property values in another script, which should get custom properties and show in UI. Here is how I am doing.
P.S. Debug shows that roomInfo.CustomProperties.Count equals to 0
public void InitializeRoom(RoomInfo roomInfo) { playerNameText.text = roomInfo.Name; maxPlayers.text = roomInfo.MaxPlayers.ToString(); currentPlayers.text = roomInfo.PlayerCount.ToString();
foreach (var customProperty in roomInfo.CustomProperties)
{
if (customProperty.Key.ToString() == CustomPropertyKeys.LosePointsPropertiesKey)
{
pointsToLose.text = customProperty.Value.ToString();
}
else if (customProperty.Key.ToString() == CustomPropertyKeys.SoqqaPropertiesKey)
{
soqqaAmount.text = customProperty.Value.ToString();
}
}
Hello, I'm having the same problem right now. How did you solve it?