Serialization in PhotonServer
Comments
-
0
-
I don't understand what is it "typeCode" there and what should I write there.
here is my code on Common
https://pastebin.com/tLpGu4xD (use pastebin because there many code and it's looks bad on this site)
and on ServerProtocol.TryRegisterCustomType(typeof(Vector2Net), idkwhatthere, Vector2Net.Serialize, Vector2Net.Deserialize);
As you see, I just need Vector2 on Server.0 -
And I'm a bit don't understand. Shall I deserialize/serialize it on server or on client on or both of them??0
-
I don't understand what is it "typeCode" there and what should I write there.It's just a byte to identify the custom type.Shall I deserialize/serialize it on server or on client on or both of them??
Yes you should implement custom type registration on both ends, if you use C# client then the code should be exactly the same.
Here is PUN's version of the Serilization in Photon doc you can find:
- the custom types included in PUN by default.
- the code used for Unity's Vector2.0 -
Thanks. I did "Byte" to identify custom type but still have one problem
public static object Deserialize(byte[] data) { Vector2Net result = new Vector2Net(); result.x = data[0]; result.y = data[1]; return result; } public static byte[] Serialize(object customType) { Vector2Net newVector = (Vector2Net)customType; return new byte[] { newVector }; }
How to I should serialize? what return?0 -
FOUND SOLUTION! I used an example from Photon.MMO Project!0
-
Can I ask you something , Serialize data in sever and send event, but raiseEvent in client i have problem, Deserialize data from raiseEvent
pressed type object but
can't get value0 -
you managed to fix it - that is very good news
best,
ilya0