Can not serialize a custom array HELP!

Options
Hello fellows ,
I am trying to serialize a custom array. like this ;


public static readonly byte[] memState = new byte[4 * 2 + 2];
// 1 short - 2 float = 80 bit = 10 byte
private static short SerializeState(StreamBuffer outStream, object customobject)
{
// reference it
State state = (State)customobject;

// serialize array
byte[] projectileArr = Protocol.Serialize(state.projectiles); // This line throwing an error.

int i = memState.Length + projectileArr.Length;

lock (memState)
{
byte[] bytes = new byte[memState.Length + projectileArr.Length]; // a byte array size of state

int index = 0;

Protocol.Serialize(state.sequence, bytes, ref index); // Sequence of packet
Protocol.Serialize(state.position.x, bytes, ref index); // x position
Protocol.Serialize(state.position.y, bytes, ref index); // y position

System.Array.Copy(projectileArr, 0, bytes, index, projectileArr.Length);

index += projectileArr.Length;

outStream.Write(bytes, 0, (10 + state.projectiles.Length * (4 * 2)));
}

int count = 10 + state.projectiles.Length * (4 * 2);

return (short)count;
}


That is the output ; NotSupportedException: cannot serialize array of type ProjectileState
Detailed ;
NotSupportedException: cannot serialize array of type ProjectileState ExitGames.Client.Photon.Protocol16.SerializeArray (ExitGames.Client.Photon.StreamBuffer dout, System.Array serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.IProtocol.Serialize (System.Object obj) ExitGames.Client.Photon.Protocol.Serialize (System.Object obj) CustomTypes.SerializeState (ExitGames.Client.Photon.StreamBuffer outStream, System.Object customobject) (at Assets/_External/Photon Unity Networking/Plugins/PhotonNetwork/CustomTypes.cs:187) ExitGames.Client.Photon.Protocol16.SerializeCustom (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeObjectArray (ExitGames.Client.Photon.StreamBuffer dout, System.Object[] objects, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType) ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters) ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType) ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opCode, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt) ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType) ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted) ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId, Boolean encrypt) LoadBalancingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/_External/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:776) NetworkingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/_External/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:975) NetworkingPeer.RunViewUpdate () (at Assets/_External/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4071) PhotonHandler.Update () (at Assets/_External/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:164)

What do you guys think ?

Comments