Photon Serialization for Database Storage

dkoss
dkoss
We want to store Serialized information about GameObjects in Parse (http://www.parse.com), so when all players leave the scene the location they left objects in is preserved.

I'd like to use Photon Serialization (as it already handles Vector3, Vector2, etc) to store a binary blob of data in Parse, representing our persisting objects. I want to grab the binary data that it is serialized by Photon and stash that in Parse. I'm trying something like:
   // stream variable already has serialized data in it
   public void SaveToParse(PhotonStream stream)
   {
       ParseObject testObject = new ParseObject("TestObjects");
       testObject["testData"] = stream.ToArray();
       testObject.SaveAsync();
   }
However, unlike the C# BinaryFormatter whose ToArray yields a byte[], PhotonStream yields an Object[], which I am not sure what to do with.

I'd appreciate any advice, and am curious what other folks have done to store Photon serialized data in a database.

Comments

  • PhotonStream actually is an array of objects ready for serialization.
    If you want to exploit Photon serialization to byte[], try ExitGames.Client.Photon.Protocol.Serialize method with stream.ToArray() or other container with your data as argument.
    The counterpart would be ExitGames.Client.Photon.Protocol.Deserialize
  • Perfect, thanks!