Photon Unity Networking 2
2.12
|
Groups the most important classes that you need to understand early on. More...
Classes | |
class | PhotonNetwork |
The main class to use the PhotonNetwork plugin. This class is static. More... | |
class | PhotonView |
A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances. More... | |
struct | PhotonMessageInfo |
Container class for info about a particular message, RPC or update. More... | |
class | PhotonStream |
This container is used in OnPhotonSerializeView() to either provide incoming data of a PhotonView or for you to provide it. More... | |
Enumerations | |
enum | ClientState |
State values for a client, which handles switching Photon server types, some operations, etc. More... | |
enum | PunLogLevel |
Used to define the level of logging output created by the PUN classes. Either log errors, info (some more) or full. More... | |
enum | RpcTarget |
Enum of "target" options for RPCs. These define which remote clients get your RPC call. More... | |
Functions | |
void | OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) |
Called by PUN several times per second, so that your script can write and read synchronization data for the PhotonView. More... | |
Detailed Description
Groups the most important classes that you need to understand early on.
Enumeration Type Documentation
|
strong |
State values for a client, which handles switching Photon server types, some operations, etc.
Enumerator | |
---|---|
PeerCreated |
Peer is created but not used yet. |
Authenticating |
Transition state while connecting to a server. On the Photon Cloud this sends the AppId and AuthenticationValues (UserID). |
Authenticated |
Not Used. |
JoiningLobby |
The client sent an OpJoinLobby and if this was done on the Master Server, it will result in. Depending on the lobby, it gets room listings. |
JoinedLobby |
The client is in a lobby, connected to the MasterServer. Depending on the lobby, it gets room listings. |
DisconnectingFromMasterServer |
Transition from MasterServer to GameServer. |
ConnectingToGameServer |
Transition to GameServer (client authenticates and joins/creates a room). |
ConnectedToGameServer |
Connected to GameServer (going to auth and join game). |
Joining |
Transition state while joining or creating a room on GameServer. |
Joined |
The client entered a room. The CurrentRoom and Players are known and you can now raise events. |
Leaving |
Transition state when leaving a room. |
DisconnectingFromGameServer |
Transition from GameServer to MasterServer (after leaving a room/game). |
ConnectingToMasterServer |
Connecting to MasterServer (includes sending authentication values). |
Disconnecting |
The client disconnects (from any server). This leads to state Disconnected. |
Disconnected |
The client is no longer connected (to any server). Connect to MasterServer to go on. |
ConnectedToMasterServer |
Connected to MasterServer. You might use matchmaking or join a lobby now. |
ConnectingToNameServer |
Client connects to the NameServer. This process includes low level connecting and setting up encryption. When done, state becomes ConnectedToNameServer. |
ConnectedToNameServer |
Client is connected to the NameServer and established encryption already. You should call OpGetRegions or ConnectToRegionMaster. |
DisconnectingFromNameServer |
Clients disconnects (specifically) from the NameServer (usually to connect to the MasterServer). |
|
strong |
Used to define the level of logging output created by the PUN classes. Either log errors, info (some more) or full.
|
strong |
Enum of "target" options for RPCs. These define which remote clients get your RPC call.
Function Documentation
void OnPhotonSerializeView | ( | PhotonStream | stream, |
PhotonMessageInfo | info | ||
) |
Called by PUN several times per second, so that your script can write and read synchronization data for the PhotonView.
This method will be called in scripts that are assigned as Observed component of a PhotonView.
PhotonNetwork.SerializationRate affects how often this method is called.
PhotonNetwork.SendRate affects how often packages are sent by this client.
Implementing this method, you can customize which data a PhotonView regularly synchronizes. Your code defines what is being sent (content) and how your data is used by receiving clients.
Unlike other callbacks, OnPhotonSerializeView only gets called when it is assigned to a PhotonView as PhotonView.observed script.
To make use of this method, the PhotonStream is essential. It will be in "writing" mode" on the client that controls a PhotonView (PhotonStream.IsWriting == true) and in "reading mode" on the remote clients that just receive that the controlling client sends.
If you skip writing any value into the stream, PUN will skip the update. Used carefully, this can conserve bandwidth and messages (which have a limit per room/second).
Note that OnPhotonSerializeView is not called on remote clients when the sender does not send any update. This can't be used as "x-times per second Update()".
Implemented in PhotonAnimatorView, CullingHandler, PhotonTransformViewClassic, PhotonTransformView, PhotonRigidbodyView, PhotonRigidbody2DView, and SmoothSyncMovement.