Photon Unity Networking v1.101

Public Member Functions | Properties | List of all members
PhotonStream Class Reference

This container is used in OnPhotonSerializeView() to either provide incoming data of a PhotonView or for you to provide it. More...

Public Member Functions

 PhotonStream (bool write, object[] incomingData)
 Creates a stream and initializes it. Used by PUN internally. More...
 
void SetReadStream (object[] incomingData, byte pos=0)
 
object ReceiveNext ()
 Read next piece of data from the stream when isReading is true. More...
 
object PeekNext ()
 Read next piece of data from the stream without advancing the "current" item. More...
 
void SendNext (object obj)
 Add another piece of data to send it when isWriting is true. More...
 
object[] ToArray ()
 Turns the stream into a new object[]. More...
 
void Serialize (ref bool myBool)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref int myInt)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref string value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref char value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref short value)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref float obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref PhotonPlayer obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Vector3 obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Vector2 obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 
void Serialize (ref Quaternion obj)
 Will read or write the value, depending on the stream's isWriting value. More...
 

Properties

bool isWriting [get]
 If true, this client should add data to the stream to send it. More...
 
bool isReading [get]
 If true, this client should read data send by another client. More...
 
int? Count [get]
 Count of items in the stream. More...
 

Detailed Description

This container is used in OnPhotonSerializeView() to either provide incoming data of a PhotonView or for you to provide it.

The isWriting property will be true if this client is the "owner" of the PhotonView (and thus the GameObject). Add data to the stream and it's sent via the server to the other players in a room. On the receiving side, isWriting is false and the data should be read.

Send as few data as possible to keep connection quality up. An empty PhotonStream will not be sent.

Use either Serialize() for reading and writing or SendNext() and ReceiveNext(). The latter two are just explicit read and write methods but do about the same work as Serialize(). It's a matter of preference which methods you use.

See also
PhotonNetworkingMessage

Constructor & Destructor Documentation

◆ PhotonStream()

PhotonStream.PhotonStream ( bool  write,
object[]  incomingData 
)

Creates a stream and initializes it. Used by PUN internally.

Member Function Documentation

◆ PeekNext()

object PhotonStream.PeekNext ( )

Read next piece of data from the stream without advancing the "current" item.

◆ ReceiveNext()

object PhotonStream.ReceiveNext ( )

Read next piece of data from the stream when isReading is true.

◆ SendNext()

void PhotonStream.SendNext ( object  obj)

Add another piece of data to send it when isWriting is true.

◆ Serialize() [1/10]

void PhotonStream.Serialize ( ref bool  myBool)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [2/10]

void PhotonStream.Serialize ( ref char  value)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [3/10]

void PhotonStream.Serialize ( ref float  obj)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [4/10]

void PhotonStream.Serialize ( ref int  myInt)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [5/10]

void PhotonStream.Serialize ( ref PhotonPlayer  obj)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [6/10]

void PhotonStream.Serialize ( ref Quaternion  obj)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [7/10]

void PhotonStream.Serialize ( ref short  value)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [8/10]

void PhotonStream.Serialize ( ref string  value)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [9/10]

void PhotonStream.Serialize ( ref Vector2  obj)

Will read or write the value, depending on the stream's isWriting value.

◆ Serialize() [10/10]

void PhotonStream.Serialize ( ref Vector3  obj)

Will read or write the value, depending on the stream's isWriting value.

◆ SetReadStream()

void PhotonStream.SetReadStream ( object[]  incomingData,
byte  pos = 0 
)

◆ ToArray()

object [] PhotonStream.ToArray ( )

Turns the stream into a new object[].

Property Documentation

◆ Count

int? PhotonStream.Count
get

Count of items in the stream.

◆ isReading

bool PhotonStream.isReading
get

If true, this client should read data send by another client.

◆ isWriting

bool PhotonStream.isWriting
get

If true, this client should add data to the stream to send it.