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-
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.
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.
0
Comments
-
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.0 -
Thanks for clarifying. I will have to send the keys and values separately and reconstruct the dictionary.0
-
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 aDictionary<keyT, object>
and then send custom types.0