photonView not syncing typeof Dictionary<K,V>

Hi, I have been using PUN for about 6 months now and I am pretty comfortable using Photon's basic features proficiently (i.e, I avoid registering custom types xD)

I am trying to sync a Dictionary<short, float> using OnPhotonSerializeView,
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            stream.SendNext(damageList);
        }

        else
        {
            damageList = (Dictionary&lt;short, float&gt;)stream.ReceiveNext();
        }
    }

No errors are thrown, and every other aspect of Photon continues to work flawless (updating object position, rotation, sending RPCs).

By way of Visual Studio debugging, I can verify the master client (the only client serializing) is in fact executing SendNext(damageList);, but on the other clients ReceiveNext(); is never being called.

I am using "Unreliable On Change". The views are attached to a GO which are PhotonNetwork.Instantiated at runtime.

Am I missing something with syncing a dictionary? Does it matter how large the dictionary is? In this case, the dictionary has three KeyValuePairs.

Comments

  • Hi,

    Did you try observing option other than "Unreliable On Change"?
    If this will help then change check fails on dictionaries comparison.
    In that case can you try to 'flatten' dictionary in sequence of shorts and floats?
  • I tried other options with no effect. I created a couple methods for flattening the dictionary to an object array on SendNext and reversing the operation on ReceieveNext and that is a working solution! It's probably more efficient too. Thanks for the tip.