Serialization of 2+ arrays of a custom type

Hello devs,

This is a very specific question about how PhotonStream.SendNext() serializes stuff. I've got an IPunObservable behaviour which needs to send 2 arrays of MyCustomClass (stored in m_Arr1 and m_Arr2 before sending). MyCustomClass has functioning De/Serialization methods in CustomTypes, but it does not have a fixed serialization length.
if (stream.IsWriting)
{
    stream.SendNext(m_Arr1);
    stream.SendNext(m_Arr2);
    // arrays get emptied
}
else
{
    m_Arr3 = (MyCustomClass[])stream.ReceiveNext();
    m_Arr4 = (MyCustomClass[])stream.ReceiveNext();
    // do stuff with m_Arr3 and m_Arr4
}
I want to make sure that m_Arr3 will only receive the elements that were in m_Arr1, and none of the ones in m_Arr2. If written like this, will Photon ensure that this is the case? And will it still do so if using UDP protocol?

Based on your serialization notes, I'm guessing the answer is yes, but I wanted to get this confirmed.

Thank you.

(What I'm using)
Unity 2018.1.0f2
PUN 1.91
PUN Voice 1.16
Sign In or Register to comment.