Photon - Syncing custom classes

Hi,

I’m currently using ‘OnPhotonSerializeView’ to sync up various variables in my multiplayer game. However, my latest challenge has been trying to sync up my List, nation being a custom class I have declared. From looking online, I’m aware I must serialize the Nation class before I can send it across but I’ve not been able to find any answers which seem applicable to my situation.

I’m receiving: Exception: cannot serialize(): System.Collections.Generic.List`1[Nation]

How would I go about serializing my custom class?

If anyone can help out, much appreciated

There is a CustomTypes class in PUN, which defines Vector3, etc. You should be able to use this as blueprint.
Keep in mind that custom types are serialized with 4 additional bytes, so if you just need to send a byte (Nation ID, e.g.), you could probably send a byte instead.

1 Like