Serializing custom types

edited July 2010 in Photon Server

In an operation response & request, I would like to be able to send my own custom class. For example, I've created my own vector class that is shared between the client & the server. In my Operation-derived class, I would like to define a property like so:

[ResponseParameter( Code=(short)ParameterCode.Position, IsOptional=false )]
public Vector2 Position { get; set; }

Will Photon automatically know how to serialize my Vector2 into an array of bytes (which is what seems to be sent over the network for an operation)? Can someone provide instructions on how to make this work?


  • BorisBoris ✭✭
    Custom types don't work out of the box, but you can use byte[] as property type and define an implicit or explicit cast operator that converts your custom class into byte[] and the other way around.
    Thanks for the idea though, will add it to the feature wish list for future versions.
  • Custom.Convert allows you to convert them to bytes, though in this case you would likely prefer to send it as float[] instead
Sign In or Register to comment.