serialize struct
Comments
-
You could indeed add your struct to the CustomTypes.cs:
in Register()PhotonPeer.RegisterType(typeof(MyStructType), (byte)'Z', SerializeMyStruct, DeserializeMyStruct);
Then also add the methods:private static byte[] SerializeMyStruct(object input){ //TODO } private static object DeserializeMyStruct(byte[] input){ //TODO }
In these two functions you'll have to serialize your struct into an byte[] as shown for the other types.0 -
Well, when i try to sync a object array with RPC, it seems that i have to add the amount of the array lenght to the rpc function parameters. How do i only collect the array instead of its unpacked?0
-
would u like to example me how i should get photon to sync this struct?
I dont know what to do inside the place where u have the //TODOpublic struct playerData { public string name; public int seatid; public int money; }
thanks0 -
Sorry, we can't write your code. We did this with Vector3 and others in the PUN class CustomTypes. Look it up in the Unity project, then it will become obvious what to do.1