SerializePhotonPlayer









How do I use Serialize Photon Player
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: CustomTypes.cs Copy
32     internal static void Register()
33     {
34         PhotonPeer.RegisterType(typeof(Vector2), (byte)'W', SerializeVector2, DeserializeVector2);
35         PhotonPeer.RegisterType(typeof(Vector3), (byte)'V', SerializeVector3, DeserializeVector3);
36         PhotonPeer.RegisterType(typeof(Quaternion), (byte)'Q', SerializeQuaternion, DeserializeQuaternion);
37         PhotonPeer.RegisterType(typeof(PhotonPlayer), (byte)'P', SerializePhotonPlayer, DeserializePhotonPlayer);
38     }
File name: CustomTypes.cs Copy
146     private static short SerializePhotonPlayer(MemoryStream outStream, object customobject)
147     {
148         int ID = ((PhotonPlayer)customobject).ID;
149
150         lock (memPlayer)
151         {
152             byte[] bytes = memPlayer;
153             int off = 0;
154             Protocol.Serialize(ID, bytes, ref off);
155             outStream.Write(bytes, 0, 4);
156             return 4;
157         }
158     }
File name: CustomTypes.cs Copy
160     private static object DeserializePhotonPlayer(MemoryStream inStream, short length)
161     {
162         int ID;
163         lock (memPlayer)
164         {
165             inStream.Read(memPlayer, 0, length);
166             int off = 0;
167             Protocol.Deserialize(out ID, memPlayer, ref off);
168         }
169
170         if (PhotonNetwork.networkingPeer.mActors.ContainsKey(ID))
171         {
172             return PhotonNetwork.networkingPeer.mActors[ID];
173         }
174         else
175         {
176             return null;
177         }
178     }

SerializePhotonPlayer 132 lượt xem

Gõ tìm kiếm nhanh...