Serialize a List of type Photon.Realtime.Player

Duck
Duck
Hello everyone,

I don't really understand how to serialize a List of type Photon.Realtime.Player. I want to pass some lists as parameters in my RPC function and one of these lists is a List of type Player. Now I get an Error and I know I have to serialize this. And I looked at some forum posts about serializing Vector2 and some other posts, but I still can't understand how to serialize a List<Player>.

Thank you already in advance.

PS: Is it bad (for the traffic or for the messages) to pass many parameters in my RPC function, especially Lists. Now I pass 10 parameters (float, float, float, bool, byte, byte, List<byte>, List<byte>, List<byte> and List<Player>). I mean, is it not recommended to pass 10 parameters in one RPC and 4 of them are lists or is it ok to do this?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Duck,

    PUN registers Player class as custom type for serialization already (see this) and the client sends ActorNumber only.
    Photon Serialization does not support generic List (see here) or List of custom types.
    Change the List to array and try again.

    Otherwise, yes, you should optimize your RPCs and reduce parameters to a minimum.
  • Hello @JohnTube
    Yes, that was also my idea, which I've got after I posted that. But I didn't have time to try it. I will try it later and I'm sure that it will work.
    But does it have impactful and serious consequences if I use many parameters or is it rather just a recommendation to use as many as possible?

    And I also wanted to ask if requests for the Master Client or the Nickname send messages to the server which are counting for the messages/s limit in one room. So do I "waste" messages when I ask if I'm the Master Client or when I get my Nickname?
    if(PhotonNetwork.IsMasterClient)
    {
    // Do something
    }

    Thank you very very much for your help and for your time