Dictionary serialization does only work with primitive value types

Options
It seems that Photon can only serialize Dictionaries as long as their value type is a C# language primitive:

>stream.SendNext(1f); //works
>stream.SendNext(new Dictionary {{0, 1f}}); //works
>stream.SendNext(Vector3.one); //works
>stream.SendNext(new Dictionary {{0, Vector3.one}}); //does not work

for the last line, I get:
>InvalidDataException: Unexpected - cannot serialize Dictionary with value type: UnityEngine.Vector3

Is this known? If so, are there any ways to get this working? I'm aware I could simply serialize all primitives of the type separately (in this example: 3 Dictionary for vector3.x, vector3.y, vector3.z), but I'm looking for a clean and standardized solution that I can apply to all my own registered custom data types. Thanks!

Comments

  • Tobias
    Options
    I just checked PUN 2 and that works:

    Dictionary<byte, object> content = new Dictionary<byte, object>(); content.Add(1, Vector3.down); PhotonNetwork.RaiseEvent(11, content, RaiseEventOptions.Default, SendOptions.SendReliable);

    Your snippet does not seem to use a generic Dictionary? Photon only supports those.
    Overall, it should work. It may be the nesting deepness or the Dictionary not being generic.
  • jRocket
    Options
    Hi did you ever figure this out? I am having the same issue, even on a new project with the latest PUN 2. If I have either a key or a value of a dictionary as a non-basic type, i get that InvalidDataException.