SendNext









How do I use Send Next
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PickupController.cs Copy
286     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
287     {
288         if (stream.isWriting)
289         {
290             stream.SendNext(this.transform.position);
291             stream.SendNext((byte)this._characterState);
292         }
293         else
294         {
295             bool initialRemotePosition = (remotePosition == Vector3.zero);
296
297             remotePosition = (Vector3)stream.ReceiveNext();
298             this._characterState = (PickupCharacterState)((byte)stream.ReceiveNext());
299
300             if (initialRemotePosition)
301             {
302                 // avoids lerping the character from "center" to the "current" position when this client joins
303                 this.transform.position = remotePosition;
304             }
305         }
306     }
File name: ThirdPersonNetwork.cs Copy
31     void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
32     {
33         if (stream.isWriting)
34         {
35             //We own this player: send the others our data
36             stream.SendNext((int)controllerScript._characterState);
37             stream.SendNext(transform.position);
38             stream.SendNext(transform.rotation);
39         }
40         else
41         {
42             //Network player, receive data
43             controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();
44             correctPlayerPos = (Vector3)stream.ReceiveNext();
45             correctPlayerRot = (Quaternion)stream.ReceiveNext();
46         }
47     }
File name: NetworkCharacter.cs Copy
17     void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
18     {
19         if (stream.isWriting)
20         {
21             // We own this player: send the others our data
22             stream.SendNext(transform.position);
23             stream.SendNext(transform.rotation);
24
25             myThirdPersonController myC = GetComponent();
26             stream.SendNext((int)myC._characterState);
27         }
28         else
29         {
30             // Network player, receive data
31             this.correctPlayerPos = (Vector3)stream.ReceiveNext();
32             this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
33
34             myThirdPersonController myC = GetComponent();
35             myC._characterState = (CharacterState)stream.ReceiveNext();
36         }
37     }
File name: PhotonAnimatorView.cs Copy
234     void SerializeDataContinuously()
235     {
236         if( m_Animator == null )
237         {
238             return;
239         }
240
241         for( int i = 0; i < m_SynchronizeLayers.Count; ++i )
242         {
243             if( m_SynchronizeLayers[ i ].SynchronizeType == SynchronizeType.Continuous )
244             {
245                 m_StreamQueue.SendNext( m_Animator.GetLayerWeight( m_SynchronizeLayers[ i ].LayerIndex ) );
246             }
247         }
248
249         for( int i = 0; i < m_SynchronizeParameters.Count; ++i )
250         {
251             SynchronizedParameter parameter = m_SynchronizeParameters[ i ];
252
253             if( parameter.SynchronizeType == SynchronizeType.Continuous )
254             {
255
256                 switch( parameter.Type )
257                 {
258                 case ParameterType.Bool:
259                     m_StreamQueue.SendNext( m_Animator.GetBool( parameter.Name ) );
260                     break;
261                 case ParameterType.Float:
262                     m_StreamQueue.SendNext( m_Animator.GetFloat( parameter.Name ) );
263                     break;
264                 case ParameterType.Int:
265                     m_StreamQueue.SendNext( m_Animator.GetInteger( parameter.Name ) );
266                     break;
267                 case ParameterType.Trigger:
268
269                     break;
270                 }
271             }
272         }
273     }
File name: PhotonAnimatorView.cs Copy
315     void SerializeDataDiscretly( PhotonStream stream )
316     {
317         for( int i = 0; i < m_SynchronizeLayers.Count; ++i )
318         {
319             if( m_SynchronizeLayers[ i ].SynchronizeType == SynchronizeType.Discrete )
320             {
321                 stream.SendNext( m_Animator.GetLayerWeight( m_SynchronizeLayers[ i ].LayerIndex ) );
322             }
323         }
324
325         for( int i = 0; i < m_SynchronizeParameters.Count; ++i )
326         {
327             SynchronizedParameter parameter = m_SynchronizeParameters[ i ];
328
329             if( parameter.SynchronizeType == SynchronizeType.Discrete )
330             {
331                 switch( parameter.Type )
332                 {
333                 case ParameterType.Bool:
334                     stream.SendNext( m_Animator.GetBool( parameter.Name ) );
335                     break;
336                 case ParameterType.Float:
337                     stream.SendNext( m_Animator.GetFloat( parameter.Name ) );
338                     break;
339                 case ParameterType.Int:
340                     stream.SendNext( m_Animator.GetInteger( parameter.Name ) );
341                     break;
342                 case ParameterType.Trigger:
343
344                     break;
345                 }
346             }
347         }
348     }
File name: PhotonAnimatorView.cs Copy
400     void SerializeSynchronizationTypeState( PhotonStream stream )
401     {
402         byte[] states = new byte[ m_SynchronizeLayers.Count + m_SynchronizeParameters.Count ];
403
404         for( int i = 0; i < m_SynchronizeLayers.Count; ++i )
405         {
406             states[ i ] = (byte)m_SynchronizeLayers[ i ].SynchronizeType;
407         }
408
409         for( int i = 0; i < m_SynchronizeParameters.Count; ++i )
410         {
411             states[ m_SynchronizeLayers.Count + i ] = (byte)m_SynchronizeParameters[ i ].SynchronizeType;
412         }
413
414         stream.SendNext( states );
415     }
File name: PhotonRigidbody2DView.cs Copy
32     void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info )
33     {
34         if( stream.isWriting == true )
35         {
36             if( m_SynchronizeVelocity == true )
37             {
38                 stream.SendNext( m_Body.velocity );
39             }
40
41             if( m_SynchronizeAngularVelocity == true )
42             {
43                 stream.SendNext( m_Body.angularVelocity );
44             }
45         }
46         else
47         {
48             if( m_SynchronizeVelocity == true )
49             {
50                 m_Body.velocity = (Vector2)stream.ReceiveNext();
51             }
52
53             if( m_SynchronizeAngularVelocity == true )
54             {
55                 m_Body.angularVelocity = (float)stream.ReceiveNext();
56             }
57         }
58     }
File name: PhotonRigidbodyView.cs Copy
32     void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info )
33     {
34         if( stream.isWriting == true )
35         {
36             if( m_SynchronizeVelocity == true )
37             {
38                 stream.SendNext( m_Body.velocity );
39             }
40
41             if( m_SynchronizeAngularVelocity == true )
42             {
43                 stream.SendNext( m_Body.angularVelocity );
44             }
45         }
46         else
47         {
48             if( m_SynchronizeVelocity == true )
49             {
50                 m_Body.velocity = (Vector3)stream.ReceiveNext();
51             }
52
53             if( m_SynchronizeAngularVelocity == true )
54             {
55                 m_Body.angularVelocity = (Vector3)stream.ReceiveNext();
56             }
57         }
58     }
File name: PhotonTransformViewPositionControl.cs Copy
183     void SerializeData( Vector3 currentPosition, PhotonStream stream, PhotonMessageInfo info )
184     {
185         stream.SendNext( currentPosition );
186
187         if( m_Model.ExtrapolateOption == PhotonTransformViewPositionModel.ExtrapolateOptions.SynchronizeValues ||
188             m_Model.InterpolateOption == PhotonTransformViewPositionModel.InterpolateOptions.SynchronizeValues )
189         {
190             stream.SendNext( m_SynchronizedSpeed );
191             stream.SendNext( m_SynchronizedTurnSpeed );
192         }
193     }
File name: PhotonTransformViewRotationControl.cs Copy
28     public void OnPhotonSerializeView( Quaternion currentRotation, PhotonStream stream, PhotonMessageInfo info )
29     {
30         if( m_Model.SynchronizeEnabled == false )
31         {
32             return;
33         }
34
35         if( stream.isWriting == true )
36         {
37             stream.SendNext( currentRotation );
38         }
39         else
40         {
41             m_NetworkRotation = (Quaternion)stream.ReceiveNext();
42         }
43     }

SendNext 166 lượt xem

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