- Home /
Photon OnPhotonSerializeView - sending a custom struct - "not serializable"
Hey there,
i am currently stuck on the following problem:
Using a Photonview i want to transfer a bulk of data packed in a custom struct witch is Serializable by System.IO standarts. I want to do this unreliably so by using OnPhotonViewSerialize.
But when adding it to the stream by stream.SendNext ();
i just get the error that the given variable is not serializable.
I tried converting the struct to a byte array using a binary formatter before sending which solves the sending problem but this leaves me with a weird result at the recieving end:
The streams recieve array will have 4 objects even though i only send one object. Also the resulting data will be in type of object
which i struggle to cast back into a variable of my custom type to actually access the data.
Any hints how to tackle this problem would be nice! Thanks in advance!
Hi,
if the struct only contains types that are serializable by Photon by default (byte, int float...), you can create a Custom Type in order to serialize it directly. To see how this works and how Vector2 is serialized by Photon as an example, you can take a look at this documentation page.
Your answer
Follow this Question
Related Questions
Photon Unity - Only receiving one value. 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Making a bubble level (not a game but work tool) 1 Answer
Instantiating scene objects in Photon Multiplayer. 0 Answers