Photon Unity Networking 2 2.45

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, int 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...
 
bool CopyToListAndClear (List< object > target)
 
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 Player 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.

Constructor & Destructor Documentation

◆ PhotonStream()

PhotonStream ( bool  write,
object[]  incomingData 
)

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

Member Function Documentation

◆ PeekNext()

object PeekNext ( )

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

◆ ReceiveNext()

object ReceiveNext ( )

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

◆ SendNext()

void SendNext ( object  obj)

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

◆ Serialize() [1/10]

void Serialize ( ref bool  myBool)

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

◆ Serialize() [2/10]

void Serialize ( ref char  value)

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

◆ Serialize() [3/10]

void Serialize ( ref float  obj)

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

◆ Serialize() [4/10]

void Serialize ( ref int  myInt)

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

◆ Serialize() [5/10]

void Serialize ( ref Player  obj)

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

◆ Serialize() [6/10]

void Serialize ( ref Quaternion  obj)

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

◆ Serialize() [7/10]

void Serialize ( ref short  value)

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

◆ Serialize() [8/10]

void Serialize ( ref string  value)

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

◆ Serialize() [9/10]

void Serialize ( ref Vector2  obj)

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

◆ Serialize() [10/10]

void Serialize ( ref Vector3  obj)

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

◆ ToArray()

object [] ToArray ( )

Turns the stream into a new object[].

Property Documentation

◆ Count

int? Count
get

Count of items in the stream.

◆ IsReading

bool IsReading
get

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

◆ IsWriting

bool IsWriting
get

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