Search Unity

Third Party Photon's OnRoomPropertiesUpdate's propertiesThatChanged is always empty

Discussion in 'Multiplayer' started by QuantumCalzone, Feb 16, 2020.

  1. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    Hi there, when I want to change a room value, I'll use the below method.
    Code (CSharp):
    1. public void SetValue(RoomProperties key, int newValue)
    2.    {
    3.        if (Verbose) Debug.Log(string.Format("SetValue ( key: {0} , newValue: {1} )", key, newValue), this);
    4.  
    5.        var propertiesToSet = new Hashtable { { key, newValue } };
    6.        PhotonNetwork.CurrentRoom.SetCustomProperties(propertiesToSet);
    7.    }
    When I do so, I get a response in the below method
    Code (CSharp):
    1. public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
    2.    {
    3.        if (Verbose)
    4.        {
    5.            Debug.Log(string.Format("OnRoomPropertiesUpdate ( propertiesThatChanged: {0} )", propertiesThatChanged.Count), this);
    6.  
    7.            foreach (DictionaryEntry dictionaryEntry in propertiesThatChanged)
    8.            {
    9.                Debug.Log(string.Format("{0} | {1}", dictionaryEntry.Key, dictionaryEntry.Value), this);
    10.            }
    11.        }
    12.    }

    However, when I log the contents of propertiesThatChanged, it's always empty. Any idea what I'm doing wrong?
     
    Last edited: Feb 16, 2020
  2. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    Ah, the Hashtable you call SetCustomProperties with needs its key to be cast as a string. That fixed it for me.