PhotonStream.ReceiveNext C# (CSharp) Method

ReceiveNext() public method

Read next piece of data from the stream when isReading is true.
public ReceiveNext ( ) : object
return object
    public object ReceiveNext()
    {
        if (this.write)
        {
            Debug.LogError("Error: you cannot read this stream that you are writing!");
            return null;
        }

        object obj = this.data[this.currentItem];
        this.currentItem++;
        return obj;
    }

Usage Example

	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if(stream.isWriting)
        {
            // this is my player. need to send my actual position to the network
            stream.SendNext(transform.position);
            stream.SendNext(_charController.velocity);
            stream.SendNext(transform.rotation);

        }
        else
        {
            //this is another player. need to get his position data. then update my version of this player
            Vector3 syncPosition = (Vector3)stream.ReceiveNext();
            Vector3 syncVelocity = (Vector3)stream.ReceiveNext();
            syncEndRotation = (Quaternion)stream.ReceiveNext();

            syncStartRotation = transform.rotation;

            syncTime = 0f;
            syncDelay = Time.time - lastSynchronizationTime;
            lastSynchronizationTime = Time.time;

            syncEndPosition = syncPosition + syncVelocity * syncDelay;
            syncStartPosition = transform.position;

        }
    }
All Usage Examples Of PhotonStream::ReceiveNext