Using PhotonViews

Photon Unity Networking features PhotonViews. These essentially act exactly as their Unity Networking counterpart, allowing an object to serialize its state and send RPCs over the network. Nearly every part of PhotonView is equivalent to Network View, with a few script differences.

If you want to get the PhotonView for an object, you have two options: you can either call the static PhotonView.Get method, use GetComponent<PhotonView>(), or you can have your script inherit from Photon.MonoBehaviour and use this.photonView to get the view.

To serialize object state, add the OnPhotonSerializeView function to your script. This function takes a PhotonStream, and a PhotonMessageInfo. This works exactly like serialization in Unity Networking. ...

Get Unity Multiplayer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.