InvalidDataException: Unexpected - cannot serialize Dictionary with key type

Options
I was trying to put together a repoduction case of an issue I was having issue (https://forum.photonengine.com/discussion/13808/exception-cant-add-size-exceeded), but I noticed a different exception-

InvalidDataException: Unexpected - cannot serialize Dictionary with key type: GridCoordinate


GridCoordinate is a custom data type that I have made sure is registered with PhotonPeer.RegisterType. Does Photon support custom types as dictionary keys? It is unclear from documentation on serialization in Photon if this is supported.

Comments

  • jRocket
    Options
    This seems to apply to dictionary values as well as keys when using any reference type or struct. I tried this with two computers with two different versions of Unity and the same thing happened. Another user was also reporting this in a different thread.

    Here is my very simple code- https://pastebin.com/YM8bxZPb

    Am I doing something wrong here? Let me know if you'd like to look at the full project.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @jRocket,

    Vector3 is already a custom registered type in PUN.
    Dictionaries with custom registered types as values or keys are not supported.
    We will update the documentation to clarify this.

    Dictionaries keys and values should be of primitive/simple types only.
  • jRocket
    Options
    Thanks for clarifying. I will have to send the keys and values separately and reconstruct the dictionary.
  • Tobias
    Tobias admin
    edited May 2019
    Options
    I don't know why custom types are not supported as Dictionary value or what's going wrong exactly.
    You should be able to define a Dictionary<keyT, object> and then send custom types.