Photon Network PUN2 (Cheat Sheet) Alex Photon / Unity Photon Documentation Go Go Gadget Public Class public class ScriptName : MonoBehaviourPun Always inherit Pun from MonoBehaviour Class to get access to the PhotonView Component Connect to Photon Network void Awake() { PhotonNetwork.ConnectUsingSettings(); } Connects to Photon Network based on “PhotonServerSettings” Join / Create Room PhotonNetwork.JoinOrCreateRoom(Name.text, RoomOptions, TypedLobby.Default); Join and/or create new room .IsMine if (photonView.IsMine) Check if the input is used by myself or another client .Instantiate (PhotonNetwork.Instantiate(Prefab, new Vector2(x-value, y-value), Quaternion.identity, 0); Instatiate Prefab on Photon Network (Prefab-Name, Vector, Rotation, Type) Create RPC [PunRPC] private void FunctionName() { do something cool! } Creates a PunRPC function which can be called to distribute “something cool” over the network Call RPC on the same Component/Script photonView.RPC(“FunctionName”, RpcTarget.AllBuffered); alternatively this.GetComponent().RPC(“FunctionName”, RpcTarget.AllBuffered); Calls the “FunctionName” RPC function and distributes it to all Targets. Alternatively “this” points to the current Script Call RPC on a different Component/Script AnotherComponent.GetComponent().RPC(“FunctionName”, RpcTarget.AllBuffered); Calls the “FunctionName” RPC function of a different Component or Script and distributes it to all Targets back