Custom Type Serialization
Options
Hello everyone,
I know there is already tons of questions about this topic, but i really can't figure out.
I lost like half day to find a solution, and I'm not able to solve this.
I have a custom class called PlayerClass, I use it for my lobby:
I want to send all data via RPC call, but I know, photon doesn't support custom types automatically.
I tryed to serialize it in CustomTypes.cs (the blueprint), and when I want to Serialize the string, the error appear(cannot convert string to short).
What my script do is:
1. When new player connect, is send his PlayerClass values to MasterClient
2. MasterClient add new player to List(PlayerClass)
3. MasterClient sent to all clients in room the new list of player(and new player get the list of players too)
Someone please can just give me a hint to solve this problem?(Protocol.Serialize of non numeric type like string)
Thanks in advance
I know there is already tons of questions about this topic, but i really can't figure out.
I lost like half day to find a solution, and I'm not able to solve this.
I have a custom class called PlayerClass, I use it for my lobby:
public class PlayerClass { public int playerID; public string playerNickname; public bool isPlayerReady; }
I want to send all data via RPC call, but I know, photon doesn't support custom types automatically.
I tryed to serialize it in CustomTypes.cs (the blueprint), and when I want to Serialize the string, the error appear(cannot convert string to short).
What my script do is:
1. When new player connect, is send his PlayerClass values to MasterClient
2. MasterClient add new player to List(PlayerClass)
3. MasterClient sent to all clients in room the new list of player(and new player get the list of players too)
Someone please can just give me a hint to solve this problem?(Protocol.Serialize of non numeric type like string)
Thanks in advance
0
Comments
-
I found a solution by myself...
In serialization you have to convert your class to byte array and vice-versa.
I still don't understand how to register custom class with no numerable variables(like strings) because in Protocol.Serialize i cannot convert string to short.
This solution works for me who need help:
http://stackoverflow.com/questions/1446547/how-to-convert-an-object-to-a-byte-array-in-c-sharp
And if someone can in the future help me to solve this problem of registration I will be grateful0