Search Unity

How to Serialize a List<byte[]> from a Local Authority player

Discussion in 'Multiplayer' started by Kivak, Aug 3, 2017.

  1. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    I am trying to serialize a List<byte[]> (list of bytearrays) from a local authority player to it's remote instances on other clients.

    Ordinarily I would use a SyncVar or Synchronized List for this, but I don't see a byte[] as an available type for those. So I tried to use OnSerialize and OnDeserialize -- which worked great as long as the player was on the server, but OnSerialize is never called when the player is connected as a client.

    What is the best method to serialize a List<byte[]> from a local authority player on a client to it's remote instances?

    Thanks!
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Send the byte array to them?
     
  3. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Maybe I am missing something very simple... but how would I do that across the network?
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Depends what library you use. In the hlapi. Use command / rpc
     
  5. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Wow, now I feel silly. I completely forgot I could send it via Command/RPC. Thank you for the gentle reminder! :)