How to make use of existing serializers in a custom serzializer?

Options
Hi,

We have a custom type that we would like to serialize for storage in the player customProperties. This type contains some Vector3 fields. E.g.:
class ACustomType {
     Vector3 foo;
     Vector3 bar;
}
I'm writing a custom serializer for this type, but am wondering how I can make use of the existing Vector3 serializers for this.
public static byte[] SerializeACustomType (object o)
	{
		ACustomType a = (ACustomType ) o;

		var byteArrayLength = 2*Vector3ByteSize;

		byte[] bytes = new byte[byteArrayLength];
		int index = 0;

                //This doesn't work, as Serialise only accepts short/int/float;
		ExitGames.Client.Photon.Protocol.Serialize(a.foo, bytes, ref index);
		ExitGames.Client.Photon.Protocol.Serialize(a.bar, bytes, ref index);

		return bytes;
	}
Is my only option to duplicate the Vector3 serialization code in my custom serializer?

Thank you

Best Answer

Answers

  • sosh
    Options
    Thanks