PhotonNetwork Documentation
PhotonNetwork Documentation
v1.24
1 Main Page 1
2 General Documentation 3
6 Module Index 19
6.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7 Namespace Index 21
7.1 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
8 Hierarchical Index 23
8.1 Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
9 Class Index 25
9.1 Class List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
10 File Index 27
10.1 File List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
11 Module Documentation 29
11.1 Optional Gui Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
11.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
11.2 Public API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
11.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
11.2.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
11.2.2.1 DisconnectCause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
11.2.2.2 PeerState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11.2.2.3 PhotonLogLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
11.2.2.4 PhotonNetworkingMessage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
iv CONTENTS
11.2.2.5 PhotonTargets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
12 Namespace Documentation 35
12.1 Package Photon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
13 Class Documentation 37
13.1 ActorProperties Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.1.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.1.2.1 PlayerName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.2 AuthenticationValues Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.2.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.2.2.1 SetAuthParameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.2.2.2 SetAuthPostData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.2.2.3 SetAuthPostData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.2.4 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.3.1 AuthParameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.3.2 AuthType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.3.3 Secret . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2.4.1 AuthPostData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.3 ErrorCode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.3.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
13.3.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
13.3.2.1 AlreadyMatched . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
13.3.2.2 CustomAuthenticationFailed . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
13.3.2.3 GameClosed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.4 GameDoesNotExist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.5 GameFull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.6 GameIdAlreadyExists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.7 InternalServerError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.8 InvalidAuthentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.9 InvalidOperationCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.10 InvalidRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.11 MaxCcuReached . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
13.3.2.12 NoRandomMatchFound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
13.3.2.13 Ok . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
13.3.2.14 OperationNotAllowedInCurrentState . . . . . . . . . . . . . . . . . . . . . . . . 42
13.3.2.15 ServerFull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS v
13.3.2.16 UserBlocked . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
13.4 EventCode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
13.4.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.1 AppStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.2 AzureNodeInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.3 GameList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.4 GameListUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.5 Join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.6 Leave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.7 Match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.8 PropertiesChanged . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
13.4.2.9 QueueState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
13.4.2.10 SetProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
13.5 Extensions Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
13.5.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
13.5.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.1 AlmostEquals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.2 AlmostEquals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.3 AlmostEquals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.4 AlmostEquals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.5 Contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.6 GetPhotonView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.7 GetPhotonViewsInChildren . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.8 Merge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.9 MergeStringKeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
13.5.2.10 StripKeysWithNullValues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
13.5.2.11 StripToStringKeys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
13.5.2.12 ToStringFull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
13.6 FriendInfo Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
13.6.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.2.1 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.3 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.3.1 IsInRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.3.2 IsOnline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.3.3 Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.6.3.4 Room . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.7 GameProperties Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13.7.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
vi CONTENTS
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS vii
13.10.2.10ClientAuthenticationData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.11ClientAuthenticationParams . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.12ClientAuthenticationType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.13Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.14CreateIfNotExists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.15CustomEventContent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.16Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.17FindFriendsRequestList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.18FindFriendsResponseOnlineList . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.19FindFriendsResponseRoomIdList . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.20GameCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.21GameList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
13.10.2.22GameProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.23Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.24MasterPeerCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.25MatchMakingType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.26PeerCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.27PlayerProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.28Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.29Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.30ReceiverGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.31Remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.32RoomName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
13.10.2.33Secret . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.10.2.34TargetActorNr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.10.2.35UserId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11PBitStream Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.1 Constructor & Destructor Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.1.1 PBitStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.1.2 PBitStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.1.3 PBitStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.2.1 Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
13.11.2.2 BytesForBits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.2.3 Get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.2.4 GetNext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.2.5 Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.2.6 ToBytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.3 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.3.1 BitCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
viii CONTENTS
13.11.3.2 ByteCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.11.3.3 Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.12PhotonLagSimulationGui Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
13.12.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.2.1 OnGUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.2.2 Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.3.1 Visible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.3.2 WindowId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.3.3 WindowRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.12.4.1 Peer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.13PhotonMessageInfo Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13.13.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.2 Constructor & Destructor Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.2.1 PhotonMessageInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.2.2 PhotonMessageInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.3 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.3.1 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.4 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.4.1 photonView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.4.2 sender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.5 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.13.5.1 timestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.14PhotonNetwork Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
13.14.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.14.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.14.2.1 AllocateViewID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.14.2.2 CloseConnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.14.2.3 Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
13.14.2.4 ConnectToBestCloudServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
13.14.2.5 ConnectUsingSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
13.14.2.6 CreateRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
13.14.2.7 CreateRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
13.14.2.8 CreateRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
13.14.2.9 Destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
13.14.2.10Destroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
13.14.2.11DestroyAll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
13.14.2.12DestroyPlayerObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS ix
13.14.2.13DestroyPlayerObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
13.14.2.14Disconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13.14.2.15FetchServerTimestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13.14.2.16FindFriends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13.14.2.17GetPing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13.14.2.18GetRoomList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13.14.2.19InitializeSecurity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
13.14.2.20Instantiate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
13.14.2.21Instantiate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
13.14.2.22InstantiateSceneObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
13.14.2.23InternalCleanPhotonMonoFromSceneIfStuck . . . . . . . . . . . . . . . . . . . 71
13.14.2.24JoinRandomRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
13.14.2.25JoinRandomRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
13.14.2.26JoinRandomRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
13.14.2.27JoinRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
13.14.2.28JoinRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
13.14.2.29LeaveRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
13.14.2.30LoadLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
13.14.2.31LoadLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.32NetworkStatisticsReset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.33NetworkStatisticsToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.34OverrideBestCloudServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.35RefreshCloudServerRating . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.36RemoveRPCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
13.14.2.37RemoveRPCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
13.14.2.38RemoveRPCsInGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
13.14.2.39SendOutgoingCommands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
13.14.2.40SetLevelPrefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
13.14.2.41SetMasterClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
13.14.2.42SetPlayerCustomProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
13.14.2.43SetReceivingEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
13.14.2.44SetSendingEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
13.14.2.45UnAllocateViewID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.1 logLevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.2 MAX_VIEW_IDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.3 PhotonServerSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.4 precisionForFloatSynchronization . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.5 precisionForQuaternionSynchronization . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.6 precisionForVectorSynchronization . . . . . . . . . . . . . . . . . . . . . . . . 76
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
x CONTENTS
13.14.3.7 PrefabCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
13.14.3.8 SendMonoMessageTargets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.3.9 serverSettingsAssetFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.3.10serverSettingsAssetPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.3.11UsePrefabCache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.3.12versionPUN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.4.1 AuthValues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.4.2 autoCleanUpPlayerObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
13.14.4.3 autoJoinLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.4 automaticallySyncScene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.5 connected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.6 connectionState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.7 connectionStateDetailed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.8 countOfPlayers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.9 countOfPlayersInRooms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.10countOfPlayersOnMaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.11countOfRooms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
13.14.4.12Friends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.13FriendsListAge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.14insideLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.15isMasterClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.16isMessageQueueRunning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.17isNonMasterClientInRoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.18masterClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.19maxConnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.20NetworkStatisticsEnabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
13.14.4.21offlineMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.22otherPlayers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.23player . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.24playerList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.25playerName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.26ResentReliableCommands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.27room . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.28sendRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.29sendRateOnSerialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.30ServerAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13.14.4.31time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
13.14.4.32unreliableCommandsLimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
13.15PhotonPlayer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS xi
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
xii CONTENTS
13.17.3.3 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.4 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.5 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.6 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.7 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.8 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.9 Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.10Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.11Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.12Serialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.3.13ToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.4.1 Count . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.4.2 isReading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.17.4.3 isWriting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.18PhotonView Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
13.18.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2.1 Awake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2.2 ExecuteOnSerialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2.3 Find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2.4 Get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
13.18.2.5 Get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.2.6 OnApplicationQuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.2.7 OnDestroy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.2.8 RPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.2.9 RPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.2.10ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.1 group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.2 instantiationId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.3 observed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.4 onSerializeRigidBodyOption . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.5 onSerializeTransformOption . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.6 ownerId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.7 prefixBackup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.8 subId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.3.9 synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.4.1 instantiationData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS xiii
13.18.4.2 isMine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.4.3 isSceneView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.4.4 owner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
13.18.4.5 OwnerActorNr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.18.4.6 prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.18.4.7 viewID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.19PingCloudRegions Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.19.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.19.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.19.2.1 ConnectToBestRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
13.19.2.2 OverrideRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.2.3 PingAllRegions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.2.4 RefreshCloudServerRating . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.2.5 ResolveHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.3.1 closestRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.19.3.2 SP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.20Room Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
13.20.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.20.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.20.2.1 SetCustomProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.20.2.2 SetPropertiesListedInLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
13.20.3 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.1 autoCleanUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.2 maxPlayers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.3 name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.4 open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.5 playerCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.6 propertiesListedInLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.20.3.7 visible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.21RoomInfo Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
13.21.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.2.1 Equals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.2.2 GetHashCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.2.3 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.3.1 autoCleanUpField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.3.2 maxPlayersField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.3.3 nameField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
xiv CONTENTS
13.21.3.4 openField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.3.5 visibleField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
13.21.4 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.1 customProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.2 isLocalClientInside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.3 maxPlayers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.4 name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.5 open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.6 playerCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.7 removedFromList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.21.4.8 visible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13.22ServerSettings Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13.22.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
13.22.2 Member Enumeration Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.2.1 HostingOption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.1 FindRegionForServerAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.2 FindServerAddressForRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.3 FindServerAddressForRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.4 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.5 UseCloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.3.6 UseMyServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.1 AppID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.2 CloudServerRegionPrefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.3 DefaultAppID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.4 DefaultCloudServerUrl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.5 DefaultMasterPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.6 DefaultServerAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.7 DisableAutoOpenWizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.8 HostType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.9 RpcList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.10ServerAddress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
13.22.4.11ServerPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
14 File Documentation 99
14.1 _Doc/general.md File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
14.2 _Doc/main.md File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
14.3 _Doc/optionalGui.md File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
14.4 _Doc/photonStatsGui.md File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
CONTENTS xv
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
xvi CONTENTS
Index 108
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 1
Main Page
Introduction
Photon is a real-time multiplayer game development framework that is fast, lean and flexible. Photon consists of
a server and several client SDKs for major platforms.
∗∗Photon Unity Network (PUN)∗∗ is a special client framework which aims to re-implement and enhance the fea-
tures of Unity’s built-in networking. Under the hood, it uses Photon’s features to communicate and match players.
As the PhotonNetwork API is very similar to Unity’s built-in solution, users with prior networking experience in Unity
should feel at home immediately. An automatic converter could assist you porting existing multiplayer projects to
the Photon equivalent.
Full source code is available, so you can scale this plugin to support any type of multiplayer game you’d ever need.
This plugin is compatible with the hosted Photon Cloud service, which runs Photon Servers for you. A setup
window registers you (for free) in less than a minute.
Most notable features:
• Dead-easy API
First Steps
If you know how to use Unity’s networking, then you should feel at home with PUN, too. You might want to run the
converter (start in Wizard: ALT+P) on one of your projects and dive into the code.
To read up on PUN, this documentation is split into a General Documentation and a Public API reference documen-
tation.
Aside from that, the source of Photon Unity Networking is available to you.
2 Main Page
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 2
General Documentation
Photon
Unlike Unity’s built-in networking, PUN always connects to a dedicated server which runs a specific game logic
that provides rooms, matchmaking and in-room communication between players. Actually, Photon Unity Networking
uses more than one server behind the scenes: Several "Game Servers" run the actual rooms (matches) while a
Master will organize and match rooms.
You have two options for the server side.
The Exit Games Cloud is a service which provides hosted and load balanced Photon Servers for you, fully managed
by Exit Games. Free trials are available and subscription costs for commercial use are competi-
tively low.
The service runs a fixed logic, so you can’t implement your own server-side game logic. Instead, the clients need
to be authoritative.
Clients are separated by “application id”, which relates to your game title and a “game version”. With that, your
players won’t clash with those of another developer or older game iterations.
Follow these steps, if you bought a package with Photon Cloud Subscription in the Asset Store:
• With:
As alternative to the Photon Cloud service, you can run your own server and develop server side logic on top of our
“Load Balancing” C# solution. This gives you full control of the server logic.
4 General Documentation
First steps
When you import PUN, the "Wizard" window will popup. Either enter your email address to register for the cloud,
skip this step to enter the AppId of an existing account or switch to "self hosted" Photon to enter your server’s
address.
This creates a configuration for either the cloud service or your own Photon server in the project: PhotonServer-
Settings.
PUN consists of quite a few files, however there’s only one that truly matters: PhotonNetwork. This class contains
all functions and variables needed. If you ever have custom requirements, you can always modify the source files -
this plugin is just an implementation of Photon after all.
If you are using Unityscript, you’ll need to move the Photon Unity Networking folder to the root of your project.
To show you how this API works, here are a few examples right away.
PhotonNetwork always uses a master server and one or more game servers. The master server just manages the
currently running games on those servers.
To get a list of currently used rooms, clients have to join the Lobby on the master server. The lobby automat-
ically sends and updates the room list to clients. This is done in intervals to keep traffic low. Also, players won’t
notice each other in the Lobby and can’t send data (to prevent issues when it’s getting crowded).
PUN enters the Lobby by default on connect but, that is not a requirement: Creating and joining rooms is always
possible while on the master server. Using JoinRandomRoom, you can distribute your players across matches
quickly and hassle-free.
When a player joins or creates a room, this is sent to the master server. The master will forward the clients to a
game server where the actual gameplay is happening.
The servers are all run on dedicated machines - there is no such thing as player-hosted ‘servers’. You don’t have to
bother remembering about the server organization though, as the API all hides this for you.
PhotonNetwork.ConnectUsingSettings(“v1.0“);
The code above is required to make use of any PhotonNetwork features. It sets your client’s game version and uses
the setup-wizard’s config (stored in: PhotonServerSettings). The wizard can also be used when you host Photon
yourself. Alternatively, use Connect() and you can ignore the PhotonServerSettings file.
Versioning
The loadbalancing logic for Photon uses your appID to separate your players from anyone else’s. The same is done
by game version, which separates players with a new client from those with older clients. As we can’t guarantee
that different Photon Unity Networking versions are compatible with each other, we add the PUN version to your
game’s version before sending it (since PUN v1.7).
Next, you’ll want to join or create a room. The following code showcases some required functions:
//Join a room
PhotonNetwork.JoinRoom(roomName);
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
5
A list of currently running games is provided by the master server’s lobby. It can be joined like other rooms but only
provides and updates the list of rooms. The PhotonNetwork plugin will automatically join the lobby after connecting.
When you’re joining a room, the list will no longer update.
To display the list of rooms (in a lobby):
Alternatively, the game can use random matchmaking: It will try to join any room and fail if none has room for
another player. In that case: Create a room without name and wait until other players join it randomly.
Fully random matchmaking is not always something players enjoy. Sometimes you just want to play a certain map
or just two versus two.
In Photon Cloud and Loadbalancing, you can set arbitrary room properties and filter for those in JoinRandom.
Room properties are synced to all players in the room and can be useful to keep track of the current map, round,
starttime, etc. They are handled as Hashtable with string keys. Preferably short keys.
You can forward selected properties to the lobby, too. This makes them available for listing them and for random
matchmaking, too. Not all room properties are interesting in the lobby, so you define the set of properties for the
lobby on room creation.
Note that "ai" has no value yet. It won’t show up in the lobby until it’s set in the game via Room.SetCustom-
Properties(). When you change the values for "map" or "ai", they will be updated in the lobby with a short delay,
too.
Keep the list short to make sure your clients performance doesn’t suffer from loading the list.
In JoinRandom, you could pass a Hashtable with expected room properties and max player value. These work as
filters when the server selects a "fitting" room for you.
If you pass more filter properties, chances are lower that a room matches them. Better limit the options.
Make sure you never filter for properties that are not known to the lobby (see above).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
6 General Documentation
MonoBehaviour Callbacks
PhotonNetwork implements several callbacks to let your game know about state changes, like “connected” or “joined
a game”. Each of the methods used as callback is part of the PhotonNetworkingMessage enum. Per enum item,
the use is explained (check the tooltip when you type in e.g. PhotonNetworkingMessage.OnConnectedToPhoton).
You can add these methods on any number of MonoBehaviours, they will be called in the respective situation. The
complete list of callbacks is also in the Plugin reference.
This covers the basics of setting up game rooms. Next up is actual communication in games.
Inside a room you are able to send network messages to other connected players. Furthermore you are able to
send buffered messages that will also be sent to players that connect in the future (for spawning your player for
instance).
Sending messages can be done using two methods. Either RPCs or by using the PhotonView property OnSerialize-
PhotonView. There is more network interaction though. You can listen for callbacks for certain network events (e.-
g. OnPhotonInstantiate, OnPhotonPlayerConnected) and you can trigger some of these events (PhotonNetwork.-
Instantiate). Don’t worry if you’re confused by the last paragraph, next up we’ll explain for each of these subjects.
Groups are not synchronized when they are changed on any PhotonView. It’s up to the developer to keep photon-
views in the same groups on all clients, if that’s needed. Using different group numbers for the same photonview
on several clients will cause some inconsistent behaviour. Some network messages are checked for their receiver
group at the receiver side only, namely: RPCS that are targetted to a single player (or MasterClient) RPCS that are
buffered (AllBuffered/OthersBuffered). This includes PhotonNetwork.Instantiate (as it is buffered).
Technical reason for this: the photon server only supports interestgroups for messages that are not cached and are
not targetted at sepcific actor(s). This might change in the future.
PhotonView
PhotonView is a script component that is used to send messages (RPCs and OnSerializePhotonView). You need to
attach the PhotonView to your games gameobjects. Note that the PhotonView is very similar to Unity’s NetworkView.
At all times, you need at least one PhotonView in your game in order to send messages and optionally instanti-
ate/allocate other PhotonViews.
To add a PhotonView to a gameobject, simply select a gameobject and use: “Components/Miscellaneous/Photon
View”.
Observe Transform
If you attach a Transform to a PhotonView’s Observe property, you can choose to sync Position, Rotation and Scale
or a combination of those across the players. This can be a great help for prototyping or smaller games. Note: A
change to any observed value will send out all observed values - not just the single value that’s changed. Also,
updates are not smoothed or interpolated.
Observe MonoBehaviour
A PhotonView can be set to observe a MonoBehaviour. In this case, the script’s OnPhotonSerializeView method
will be called. This method is called for writing an object’s state and for reading it, depending on whether the script
is controlled by the local player.
The simple code below shows how to add character state synchronization with just a few lines of code more:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
7
If you send something “ReliableDeltaCompressed”, make sure to always write data to the stream in the same order.
If you write no data to the PhotonStream, the update is not sent. This can be useful in pauses. Now on, to yet
another way to communicate: RPCs.
Remote Procedure Calls (RPCs) are exactly what the name implies: methods that can be called on remote clients
in the same room. To enable remote calls for a method of a MonoBehaviour, you must apply the attribute: [RPC]. A
PhotonView instance is needed on the same GameObject, to call the marked functions.
[RPC]
void ChatMessage(string a, string b)
{
Debug.Log("ChatMessage " + a + " " + b);
}
To call the method from any script, you need access to a PhotonView object. If your script derives from Photon.-
MonoBehaviour, it has a photonView field. Any regular MonoBehaviour or GameObject can use: PhotonView.-
Get(this) to get access to its PhotonView component and then call RPCs on it.
So, instead of directly calling the target method, you call RPC() on a PhotonView. Provide the name of the method
to call, which players should call the method and then provide a list of parameters.
Careful: The parameters list used in RPC() has to match the number of expected parameters! If the receiving client
can’t find a matching method, it will log an error. There is one exception to this rule: The last parameter of a RPC
method can be of type PhotonMessageInfo, which will provide some context for each call.
[RPC]
void ChatMessage(string a, string b, PhotonMessageInfo info)
{
Debug.Log(String.Format("Info: {0} {1} {2}", info.sender, info.
photonView, info.timestamp));
}
RPCs are called on specific PhotonViews and always target the matching one on the remote client. If the remote
client does not know the fitting PhotonView, the RPC is lost.
A typical cause for lost RPCs is when clients load and set up levels. One client is faster or in the room for a longer
time and sends important RPCs for objects that are not yet loaded on the other clients. The same happens when
RPCs are buffered.
The solution is to pause the message queue, while during scene setup:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
8 General Documentation
Disabling the message queue will delay incoming and outgoing messages until the queue is unlocked. Obviously,
it’s very important to unlock the queue when you’re ready to go on.
RPCs that belonged to the previously loaded scene but still arrived will now be discarded. But you should be able
to define a break between both scenes by RPC.
Various topics
1. Host model
• Unity networking is server-client based (NOT P2P!). Servers are run via a Unity client (so via one of the
players)
• Photon is server-client based as well, but has a dedicated server; No more dropped connections due to
hosts leaving.
2. Connectivity
• Unity networking works with NAT punchthrough to try to improve connectivity: since players host the
network servers, the connection often fails due to firewalls/routers etc. Connectivity can never be guar-
anteed, there is a low success rate.
• Photon has a dedicated server, there is no need for NAT punchthrough or other concepts. Connectivity
is a guaranteed 100%. If, in the rare case, a connection fails it must be due to a very strict client side
network (a business VPN for example).
3. Performance
• Photon beats Unity networking performance wise. We do not have the figures to prove this yet but the
library has been optimized for years now. Furthermore, since the Unity servers are player hosted la-
tency/ping is usually worse; you rely on the connection of the player acting as server. These connections
are never any better then the connection of your dedicated Photon server.
4. Price
• Like the Unity Networking solution, the Photon Unity Networking plugin is free as well. You can subscribe
to use Photon Cloud hosting service for your game. Alternatively, you can rent your own servers and run
Photon on them. The free license enables up to 100 concurrent players. Other licenses cost a one-time
fee (as you do the hosting) and lift the concurrent user limits.
• Unity does not seem to give much priority to their Networking implementation. There are rarely feature
improvements and bugfixes are as seldom. The Photon solution is actively maintained and parts of it
are available with source code. Furthermore, Photon already offers more features than Unity, such as
the built-in load balancing and offline mode.
6. Master Server
• The Master Server for Photon is a bit different from the Master Server for plain Unity Networking: In our
case, it’s a Photon Server that lists room-names of currently played games in so called “lobbies”. Like
Unity’s Master, it will forward clients to the Game Server(s), where the actual gameplay is done.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
9
In about every game you need to instantiate one or more player objects for every player. There are various options
to do so which are listed below.
PhotonNetwork.Instantiate
PUN can automatically take care of spawning an object by passing a starting position, rotation and a prefab name to
the PhotonNetwork.Instantiate method. Requirement: The prefab should be available directly under a Resources/
folder so that the prefab can be loaded at run time. Watch out with webplayers: Everything in the resources folder
will be streamed at the very first scene per default. Under the webplayer settings you can specify the first level that
uses assets from the Resources folder by using the “First streamed level”. If you set this to your first game scene,
your preloader and mainmenu will not be slowed down if they don’t use the Resources folder assets.
void SpawnMyPlayerEverywhere()
{
PhotonNetwork.Instantiate(“MyPrefabName”, new Vector3(0,0,0), Quaternion.
identity, 0);
//The last argument is an optional group number, feel free to ignore it for now.
}
If don’t want to rely on the Resources folders to instantiate objects over the network you’ll have to manually Instan-
tiate objects as shown in the example at the end of this section.
The main reason for wanting to instantiate manually is gaining control over what is downloaded when for streaming
webplayers. The details about streaming and the Resources folder in Unity can be found here.
If you spawn manually, you will have to assign a PhotonViewID yourself, these viewID’s are the key to routing
network messages to the correct gameobject/scripts. The player who wants to own and spawn a new object should
allocate a new viewID using PhotonNetwork.AllocateViewID();. This PhotonViewID should then be send to all other
players using a PhotonView that has already been set up (for example an existing scene PhotonView). You will
have to keep in mind that this RPC needs to be buffered so that any clients that connect later will also receive the
spawn instructions. Then the RPC message that is used to spawn the object will need a reference to your desired
prefab and instantiate this using Unity’s GameObject.Instantiate. Finally you will need to set setup the PhotonViews
attached to this prefab by assigning all PhotonViews a PhotonViewID.
void SpawnMyPlayerEverywhere()
{
//Manually allocate PhotonViewID
PhotonViewID id1 = PhotonNetwork.AllocateViewID();
[RPC]
void SpawnOnNetwork(Vector3 pos, Quaternion rot, PhotonViewID id1, PhotonPlayer np)
{
Transform newPlayer = Instantiate(playerPrefab, pos, rot) as Transform;
If you want to use asset bundles to load your network objects from, all you have to do is add your own assetbundle
loading code and replace the “playerPrefab” from the example with the prefab from your asset bundle.
Offline mode
Offline mode is a feature to be able to re-use your multiplayer code in singleplayer game modes as well.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
10 General Documentation
Mike Hergaarden: At M2H we had to rebuild our games several times as game portals usually require you to remove
multiplayer functionality completely. Furthermore, being able to use the same code for single and multiplayer saves
a lot of work on itself.
The most common features that you’ll want to be able to use in singleplayer are sending RPCs and using Photon-
Network.Instantiate. The main goal of offline mode is to disable nullreferences and other errors when using Photon-
Network functionality while not connected. You would still need to keep track of the fact that you’re running a
singleplayer game, to set up the game etc. However, while running the game, all code should be reusable.
You need to manually enable offline mode, as PhotonNetwork needs to be able to distinguish erroneous from
intended behaviour. Enabling this feature is very easy:
PhotonNetwork.offlineMode = true;
You can now reuse certain multiplayer methods without generating any connections and errors. Furthermore there
is no noticeable overhead. Below follows a list of PhotonNetwork functions and variables and their results during
offline mode:
PhotonNetwork.player The player ID is always -1 PhotonNetwork.playerName Works as expected. Photon-
Network.playerList Contains only the local player PhotonNetwork.otherPlayers Always empty PhotonNetwork.time
returns Time.time; PhotonNetwork.isMasterClient Always true PhotonNetwork.AllocateViewID() Works as expected.
PhotonNetwork.Instantiate Works as expected PhotonNetwork.Destroy Works as expected. PhotonNetwork.-
RemoveRPCs/RemoveRPCsInGroup/SetReceivingEnabled/SetSendingEnabled/SetLevelPrefix While these make
no sense in Singleplayer, they will not hurt either. PhotonView.RPC Works as expected.
Note that using other methods than the ones above can yield unexpected results and some will simply do nothing.
E.g. PhotonNetwork.room will, obviously, return null. If you intend on starting a game in singleplayer, but move it to
multiplayer at a later stage, you might want to consider hosting a 1 player game instead; this will preserve buffered
RPCs and Instantiation calls, whereas offline mode Instantiations will not automatically carry over after Connecting.
Either set PhotonNetwork.offlineMode = false; or Simply call Connect() to stop offline mode.
Limitations
For performance reasons, the PhotonNetwork API supports up to 1000 PhotonViews per player and a maximum of
2,147,483 players (note that this is WAY higher than your hardware can support!). You can easily allow for more
PhotonViews per player, at the cost of maximum players. This works as follows: PhotonViews send out a viewID
for every network message. This viewID is an integer and it is composed of the player ID and the player’s view ID.
The maximum size of an int is 2,147,483,647, divided by our MAX_VIEW_IDS(1000) that allows for over 2 million
players, each having 1000 view IDs. As you can see, you can easily increase the player count by reducing the
MAX_VIEW_IDS. The other way around, you can give all players more VIEW_IDS at the cost of less maximum
players. It is important to note that most games will never need more than a few view ID’s per player (one or two
for the character..and that’s usually it). If you need much more then you might be doing something wrong! It is
extremely inefficient to assign a PhotonView and ID for every bullet that your weapon fires, instead keep track of
your fire bullets via the player or weapon’s PhotonView.
There is room for improving your bandwidth performance by reducing the int to a short (value range: 32,768 to
32,768). By setting MAX_VIEW_IDS to 32 you can then still support 1023 players Search for “//LIMITS NETWO-
RKVIEWS&PLAYERS” for all occurrences of the int viewID. Furthermore, currently the API is not using uint/ushort
but only the positive range of the numbers. This is done for simplicity and the usage of viewIDs is not a crucial
performance issue for most situations.
The PhotonNetwork plugin does not support real network groups and no scoping yet. While Unity’s “scope” feature is
not implemented, the network groups are currently implemented purely client side: Any RPC that should be ignored
due to grouping, will be discarded after it’s received. This way, groups are working but won’t save bandwidth.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
11
Feedback
We are interested in your feedback, as this solution is an ongoing project for us. Let us know if something was too
hidden, missing or not working. To let us know, post in our Forum: forum.exitgames.com
F.A.Q.
Yes this is perfectly fine. You will need multiple PhotonViews if you need to observe 2 or more targets; You can
only observe one per PhotonView. For your RPC’s you’ll only ever need one PhotonView and this can be the same
PhotonView that is already observing something. RPC’s never clash with an observed target.
To be able to use the Photon classes you’ll need to move the Plugins folder to the root of your project.
Converting your Unity networking project to Photon can be done in one day. Just to be sure, make a backup of
your project, as our automated converter will change your scripts. After this is done, run the converter from the
Photon editor window (Window -> Photon Unity Networking -> Converter -> Start). The automatic conversion
takes between 30 seconds to 10 minutes, depending on the size of your project and your computers performance.
This automatic conversion takes care of the following:
• All NetworkViews are replaced with PhotonViews and the exact same settings. This is applied for all scenes
and all prefabs.
• All scripts (JS/BOO/C#) are scanned for Network API calls, and they are replaced with PhotonNetwork calls.
There are some minor differences, therefore you will need to manually fix a few script conversion bugs. After
conversion, you will most likely see some compile errors. You’ll have to fix these first. Most common compile errors:
PhotonNetwork.RemoveRPCs(player); PhotonNetwork.DestroyPlayerObjects(player); These do not exist, and can
be safely removed. Photon automatically cleans up players when they leave (even though you can disable this
and take care of cleanup yourself if you want to) ..CloseConnection takes ‘2’ arguments. . . Remove the second,
boolean, argument from this call. PhotonNetwork.GetPing(player); GetPing does not take any arguments, you can
only request the ping to the photon server, not ping to other players. myPlayerClass.transform.photonView.XX-
X error You will need to convert code like this to: myPlayerClass.transform.GetComponent<PhotonView>().XXX
Inside of scripts, you can use photonView to get the attached PhotonView component. However, you cannot call this
on an external transform directly. RegisterServer There’s no more need to register your games to a masterserver,
Photon does this automatically.
You should be able to fix all compile errors in 5-30 minutes. Most errors will originate from main menu/GUI code,
related to IPs/Ports/Lobby GUI.
This is where Photon differs most from Unity’s solution:
There is only one Photon server and you connect using the room names. Therefore all references to IPs/ports
can be removed from your code (usually GUI code). PhotonNetwork.JoinRoom(string room) only takes a room
argument, you’ll need to remove your old IP/port/NAT arguments. If you have been using the “Ultimate Unity
networking project” by M2H, you should remove the MultiplayerFunctions class.
Lastly, all old MasterServer calls can be removed. You never need to register servers, and fetching the room list is
as easy as calling PhotonNetwork.GetRoomList(). This list is always up to date (no need to fetch/poll etc). Rewriting
the room listing can be most work, if your GUI needs to be redone, it might be simpler to write the GUI from scratch.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
12 General Documentation
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 3
As tool for developers, the Photon client library can simulate network conditions for lag (message delay) and loss.
The PUN package contains a small GUI component, to set the relevant values at runtime of a game.
To use it, add the component PhotonNetSimSettingsGui to an enabled GameObject in your scene. At runtime, the
top left of the screen shows the current roundtrip time (RTT) and the controls for network simulation:
• RTT: The roundtrip time is the average of milliseconds until a message was acknowledged by the server. The
variance value (behind the +/-) shows how stable the rtt is (a lower value being better).
• "Sim" toggle: Enables and disables the simulation. A sudden, big change of network conditions might result
in disconnects.
• "Lag" slider: Adds a fixed delay to all outgoing and incoming messages. In milliseconds.
• "Loss" slider: Drops the set percentage of messages. You can expect less than 2% drop in the internet today.
14 Gui for Network Simulation
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 4
The PhotonStatsGui is a simple GUI component to shows tracked network metrics easily at runtime.
Usage
Just add the PhotonStatsGui component to any active GameObject in the hierarchy. A window appears (at runtime)
and shows the message count.
A few toggles let you configure the window:
• buttons: Show buttons for "stats on", "reset stats" and "to log"
Message Statistics
The top most values showns are counter for "messages". Any operation, response and event are counted. Shown
are the total count of outgoing, incoming and the sum of those messages as total and as average for the timespan
that is tracked.
Traffic Statistics
These are the byte and packet counters. Anything that leaves or arrives via network is counted here. Even if there
are few messages, they could be huge by accident and still cause less powerful clients to drop connection. You also
see that there are packages sent when you don’t send messages. They keeps the connection alive.
Health Statistics
The block beginning with "longest delta between" is about the performance of your client. We measure how much
time passed between consecutive calls of send and dispatch. Usually they should be called ten times per second.
If these values go beyond one second, you should check why Update() calls are delayed.
Button "Reset"
This resets the stats but keeps tracking them. This is useful to track message counts for different situations.
Pressing this simply logs the current stat values. This can be useful to have a overview how things evolved or just
as reference.
16 Gui for Network Statistics
The Photon library can track various network statistics but usually this feature is turned off. The PhotonStatsGui will
enable the tracking and show those values.
The "stats on" toggle in the Gui controls if traffic stats are collected at all. The "Traffic Stats On" checkbox in the
Inspector is the same value.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 5
The public api of PUN consists of any code that is considered useful for you as developer.
These classes are grouped into a "module" in this reference, to make it easier to learn about the important stuff of
PUN.
18 What is the public PUN api
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 6
Module Index
6.1 Modules
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 7
Namespace Index
7.1 Packages
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 8
Hierarchical Index
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 9
Class Index
Here are the classes, structs, unions and interfaces with brief descriptions:
ActorProperties
Class for constants. These (byte) values define "well known" properties for an Actor / Player.
Pun uses these constants internally. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
AuthenticationValues
Container for "Custom Authentication" values in Photon (default: user and token). Set Auth-
Parameters before connecting - all else is handled. . . . . . . . . . . . . . . . . . . . . . . . 37
ErrorCode
Class for constants. These (int) values represent error codes, as defined and sent by the Photon
LoadBalancing logic. Pun uses these constants internally. . . . . . . . . . . . . . . . . . . . 39
EventCode
Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses
these constants internally. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Extensions
This static class defines some useful extension methods for several existing classes (e.g. Vec-
tor3, float and others). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
FriendInfo
Used to store info about a friend’s online state and in which room he/she is. . . . . . . . . . . 46
GameProperties
Class for constants. These (byte) values are for "well known" room/game properties used in
Photon Loadbalancing. Pun uses these constants internally. . . . . . . . . . . . . . . . . . . 47
Photon.MonoBehaviour
This class adds the property photonView, while logging a warning when your game still uses the
networkView. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
OperationCode
Class for constants. Contains operation codes. Pun uses these constants internally. . . . . . . 49
ParameterCode
Class for constants. Codes for parameters of Operations and Events. Pun uses these constants
internally. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
PBitStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
PhotonLagSimulationGui
This MonoBehaviour is a basic GUI for the Photon client’s network-simulation feature. It can
modify lag (fixed delay), jitter (random lag) and packet loss. . . . . . . . . . . . . . . . . . . . 57
PhotonMessageInfo
Container class for info about a particular message, RPC or update. . . . . . . . . . . . . . . 58
PhotonNetwork
The main class to use the PhotonNetwork plugin. This class is static. . . . . . . . . . . . . . . 59
PhotonPlayer
Summarizes a "player" within a room, identified (in that room) by actorID. . . . . . . . . . . . . 81
26 Class Index
PhotonStatsGui
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab. 84
PhotonStream
This "container" class is used to carry your data as written by OnPhotonSerializeView. . . . . . 86
PhotonView
PUN’s NetworkView replacement class for networking. Use it like a NetworkView. . . . . . . . 87
PingCloudRegions
This script is automatically added to the PhotonHandler gameobject by PUN. It will auto-ping the
ExitGames cloud regions via Awake. This is done only once per client and the result is saved in
PlayerPrefs. Use PhotonNetwork.ConnectToBestCloudServer(gameVersion) to connect to cloud
region with best ping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Room
This class resembles a room that PUN joins (or joined). The properties are settable as opposed
to those of a RoomInfo and you can close or hide "your" room. . . . . . . . . . . . . . . . . . 91
RoomInfo
A simplified room with just the info required to list and join, used for the room listing in the lobby.
The properties are not settable (open, maxPlayers, etc). . . . . . . . . . . . . . . . . . . . . 93
ServerSettings
Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsing-
Settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 10
File Index
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 11
Module Documentation
Classes
• class PhotonLagSimulationGui
This MonoBehaviour is a basic GUI for the Photon client’s network-simulation feature. It can modify lag (fixed delay),
jitter (random lag) and packet loss.
• class PhotonStatsGui
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.
While the PUN package does not provide in-game Gui components, there are some that try to make your life as
developer easier.
30 Module Documentation
Classes
• class PhotonMessageInfo
Container class for info about a particular message, RPC or update.
• class PhotonStream
This "container" class is used to carry your data as written by OnPhotonSerializeView.
• class PhotonNetwork
The main class to use the PhotonNetwork plugin. This class is static.
• class PhotonPlayer
Summarizes a "player" within a room, identified (in that room) by actorID.
• class PhotonView
PUN’s NetworkView replacement class for networking. Use it like a NetworkView.
• class Room
This class resembles a room that PUN joins (or joined). The properties are settable as opposed to those of a Room-
Info and you can close or hide "your" room.
• class RoomInfo
A simplified room with just the info required to list and join, used for the room listing in the lobby. The properties are
not settable (open, maxPlayers, etc).
Enumerations
• enum PeerState {
PeerState.Uninitialized, PeerState.PeerCreated, PeerState.Connecting, PeerState.Connected,
PeerState.Queued, PeerState.Authenticated, PeerState.JoinedLobby, PeerState.DisconnectingFrom-
Masterserver,
PeerState.ConnectingToGameserver, PeerState.ConnectedToGameserver, PeerState.Joining, PeerState.-
Joined,
PeerState.Leaving, PeerState.DisconnectingFromGameserver, PeerState.ConnectingToMasterserver, Peer-
State.ConnectedComingFromGameserver,
PeerState.QueuedComingFromGameserver, PeerState.Disconnecting, PeerState.Disconnected, PeerState.-
ConnectedToMaster }
Detailed connection / networking peer state. PUN implements a loadbalancing and authentication workflow "behind
the scenes", so some states will automatically advance to some follow up state. Those states are commented with
"(will-change)".
• enum PhotonNetworkingMessage {
PhotonNetworkingMessage.OnConnectedToPhoton, PhotonNetworkingMessage.OnLeftRoom, Photon-
NetworkingMessage.OnMasterClientSwitched, PhotonNetworkingMessage.OnPhotonCreateRoomFailed,
PhotonNetworkingMessage.OnPhotonJoinRoomFailed, PhotonNetworkingMessage.OnCreatedRoom,
PhotonNetworkingMessage.OnJoinedLobby, PhotonNetworkingMessage.OnLeftLobby,
PhotonNetworkingMessage.OnDisconnectedFromPhoton, PhotonNetworkingMessage.OnConnectionFail,
PhotonNetworkingMessage.OnFailedToConnectToPhoton, PhotonNetworkingMessage.OnReceivedRoom-
ListUpdate,
PhotonNetworkingMessage.OnJoinedRoom, PhotonNetworkingMessage.OnPhotonPlayerConnected,
PhotonNetworkingMessage.OnPhotonPlayerDisconnected, PhotonNetworkingMessage.OnPhotonRandom-
JoinFailed,
PhotonNetworkingMessage.OnConnectedToMaster, PhotonNetworkingMessage.OnPhotonSerializeView,
PhotonNetworkingMessage.OnPhotonInstantiate, PhotonNetworkingMessage.OnPhotonMaxCccuReached,
PhotonNetworkingMessage.OnPhotonCustomRoomPropertiesChanged, PhotonNetworkingMessage.On-
PhotonPlayerPropertiesChanged, PhotonNetworkingMessage.OnUpdatedFriendList, PhotonNetworking-
Message.OnCustomAuthenticationFailed }
This enum makes up the set of MonoMessages sent by Photon Unity Networking. Implement any of these constant
names as method and it will be called in the respective situation.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
11.2 Public API 31
• enum DisconnectCause {
DisconnectCause.ExceptionOnConnect = StatusCode.ExceptionOnConnect, DisconnectCause.Security-
ExceptionOnConnect = StatusCode.SecurityExceptionOnConnect, DisconnectCause.TimeoutDisconnect
= StatusCode.TimeoutDisconnect, DisconnectCause.DisconnectByClientTimeout = StatusCode.Timeout-
Disconnect,
DisconnectCause.InternalReceiveException = StatusCode.ExceptionOnReceive, DisconnectCause.-
DisconnectByServer = StatusCode.DisconnectByServer, DisconnectCause.DisconnectByServerTimeout
= StatusCode.DisconnectByServer, DisconnectCause.DisconnectByServerLogic = StatusCode.Disconnect-
ByServerLogic,
DisconnectCause.DisconnectByServerUserLimit = StatusCode.DisconnectByServerUserLimit, Disconnect-
Cause.Exception = StatusCode.Exception, DisconnectCause.InvalidRegion = ErrorCode.InvalidRegion,
DisconnectCause.MaxCcuReached = ErrorCode.MaxCcuReached }
Summarizes the cause for a disconnect. Used in: OnConnectionFail and OnFailedToConnectToPhoton.
• enum PhotonTargets {
PhotonTargets.All, PhotonTargets.Others, PhotonTargets.MasterClient, PhotonTargets.AllBuffered,
PhotonTargets.OthersBuffered }
Enum of "target" options for RPCs. These define which remote clients get your RPC call.
• enum PhotonLogLevel { PhotonLogLevel.ErrorsOnly, PhotonLogLevel.Informational, PhotonLogLevel.Full }
Used to define the level of logging output created by the PUN classes. Either log errors, info (some more) or full.
The public api of PUN consists of any code that is considered useful for you as developer.
For documentation, we concentrate on the public api.
Opposed to that, there are several classes that are for internal use by the PUN framework. Even some of the
internally used classes are public. This is for ease of use and in parts a result of how Unity works.
Summarizes the cause for a disconnect. Used in: OnConnectionFail and OnFailedToConnectToPhoton.
Extracted from the status codes from ExitGames.Client.Photon.StatusCode.
See Also
PhotonNetworkingMessage
Enumerator
ExceptionOnConnect Connection could not be established. Possible cause: Local server not running.
SecurityExceptionOnConnect The security settings for client or server don’t allow a connection (see re-
marks).A common cause for this is that browser clients read a "crossdomain" file from the server.
If that file is unavailable or not configured to let the client connect, this exception is thrown. Pho-
ton usually provides this crossdomain file for Unity. If it fails, read: http://doc.exitgames.-
com/photon-server/PolicyApp
TimeoutDisconnect Connection timed out. Possible cause: Remote server not running or required ports
blocked (due to router or firewall).
DisconnectByClientTimeout Timeout disconnect by client (which decided an ACK was missing for too long).
InternalReceiveException Exception in the receive-loop. Possible cause: Socket failure.
DisconnectByServer Server actively disconnected this client.
DisconnectByServerTimeout Timeout disconnect by server (which decided an ACK was missing for too
long).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
32 Module Documentation
DisconnectByServerLogic Server actively disconnected this client. Possible cause: Server’s send buffer full
(too much data for client).
DisconnectByServerUserLimit Server actively disconnected this client. Possible cause: The server’s user
limit was hit and client was forced to disconnect (on connect).
Exception Some exception caused the connection to close.
InvalidRegion (32756) Authorization on the Photon Cloud failed because the app’s subscription does not
allow to use a particular region’s server.
MaxCcuReached (32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit
of the app’s subscription is reached.
Detailed connection / networking peer state. PUN implements a loadbalancing and authentication workflow "behind
the scenes", so some states will automatically advance to some follow up state. Those states are commented with
"(will-change)".
Enumerator
Uninitialized Not running. Only set before initialization and first use.
PeerCreated Created and available to connect.
Connecting Working to establish the initial connection to the master server (until this process is finished, no
operations can be sent).(will-change)
Connected Connection is setup, now PUN will exchange keys for encryption or authenticate.(will-change)
Queued Not used at the moment.
Authenticated The application is authenticated. PUN usually joins the lobby now.(will-change) Unless Auto-
JoinLobby is false.
JoinedLobby Client is in the lobby of the Master Server and gets room listings.Use Join, Create or Join-
Random to get into a room to play.
DisconnectingFromMasterserver Disconnecting.(will-change)
ConnectingToGameserver Connecting to game server (to join/create a room and play).(will-change)
ConnectedToGameserver Similar to Connected state but on game server. Still in process to join/create
room.(will-change)
Joining In process to join/create room (on game server).(will-change)
Joined Final state of a room join/create sequence. This client can now exchange events / call RPCs with
other clients.
Leaving Leaving a room.(will-change)
DisconnectingFromGameserver Workflow is leaving the game server and will re-connect to the master
server.(will-change)
ConnectingToMasterserver Workflow is connected to master server and will establish encryption and au-
thenticate your app.(will-change)
ConnectedComingFromGameserver Same as Connected but coming from game server.(will-change)
QueuedComingFromGameserver Same Queued but coming from game server.(will-change)
Disconnecting PUN is disconnecting. This leads to Disconnected.(will-change)
Disconnected No connection is setup, ready to connect. Similar to PeerCreated.
ConnectedToMaster Final state for connecting to master without joining the lobby (AutoJoinLobby is false).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
11.2 Public API 33
Used to define the level of logging output created by the PUN classes. Either log errors, info (some more) or full.
Enumerator
ErrorsOnly
Informational
Full
This enum makes up the set of MonoMessages sent by Photon Unity Networking. Implement any of these constant
names as method and it will be called in the respective situation.
Implement: public void OnLeftRoom() { //some work }
Enumerator
OnConnectedToPhoton Called when the server is available and before client authenticates. Wait for the
call to OnJoinedLobby (or OnConnectedToMaster) before the client does anything! Example: void On-
ConnectedToPhoton(){ ... } This is not called for transitions from the masterserver to game servers, which
is hidden for PUN users.
OnLeftRoom Called once the local user left a room. Example: void OnLeftRoom(){ ... }
OnMasterClientSwitched Called -after- switching to a new MasterClient because the previous MC left the
room (not when getting into a room). The last MC will already be removed at this time. Example: void
OnMasterClientSwitched(PhotonPlayer newMasterClient){ ... }
OnPhotonCreateRoomFailed Called if a CreateRoom() call failed. Most likely because the room name is
already in use. Example: void OnPhotonCreateRoomFailed(){ ... }
OnPhotonJoinRoomFailed Called if a JoinRoom() call failed. Most likely because the room does not exist or
the room is full. Example: void OnPhotonJoinRoomFailed(){ ... }
OnCreatedRoom Called when CreateRoom finishes creating the room. After this, OnJoinedRoom will be
called, too (no matter if creating one or joining). Example: void OnCreatedRoom(){ ... } This implies the
local client is the MasterClient.
OnJoinedLobby Called on entering the Master Server’s lobby. Client can create/join rooms but room list is
not available until OnReceivedRoomListUpdate is called! Example: void OnJoinedLobby(){ ... } Note:
When PhotonNetwork.autoJoinLobby is false, OnConnectedToMaster will be called instead and the room
list won’t be available. While in the lobby, the roomlist is automatically updated in fixed intervals (which
you can’t modify).
OnLeftLobby Called after leaving the lobby. Example: void OnLeftLobby(){ ... }
OnDisconnectedFromPhoton Called after disconnecting from the Photon server. In some cases, other
events are sent before OnDisconnectedFromPhoton is called. Examples: OnConnectionFail and On-
FailedToConnectToPhoton. Example: void OnDisconnectedFromPhoton(){ ... }
OnConnectionFail Called when something causes the connection to fail (after it was established), followed
by a call to OnDisconnectedFromPhoton. If the server could not be reached in the first place, OnFailed-
ToConnectToPhoton is called instead. The reason for the error is provided as StatusCode. Example: void
OnConnectionFail(DisconnectCause cause){ ... }
OnFailedToConnectToPhoton Called if a connect call to the Photon server failed before the connection was
established, followed by a call to OnDisconnectedFromPhoton. If the connection was established but then
fails, OnConnectionFail is called. Example: void OnFailedToConnectToPhoton(DisconnectCause cause){
... }
OnReceivedRoomListUpdate Called for any update of the room listing (no matter if "new" list or "update for
known" list). Only called in the Lobby state (on master server). Example: void OnReceivedRoomList-
Update(){ ... }
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
34 Module Documentation
OnJoinedRoom Called when entering a room (by creating or joining it). Called on all clients (including the
Master Client). Example: void OnJoinedRoom(){ ... }
OnPhotonPlayerConnected Called after a remote player connected to the room. This PhotonPlayer is al-
ready added to the playerlist at this time. Example: void OnPhotonPlayerConnected(PhotonPlayer new-
Player){ ... }
OnPhotonPlayerDisconnected Called after a remote player disconnected from the room. This PhotonPlayer
is already removed from the playerlist at this time. Example: void OnPhotonPlayerDisconnected(Photon-
Player otherPlayer){ ... }
OnPhotonRandomJoinFailed Called after a JoinRandom() call failed. Most likely all rooms are full or no
rooms are available. Example: void OnPhotonRandomJoinFailed(){ ... }
OnConnectedToMaster Called after the connection to the master is established and authenticated but only
when PhotonNetwork.AutoJoinLobby is false. If AutoJoinLobby is false, the list of available rooms won’t
become available but you could join (random or by name) and create rooms anyways. Example: void
OnConnectedToMaster(){ ... }
OnPhotonSerializeView Called every network ’update’ on MonoBehaviours that are being observed by a
PhotonView. Example: void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){ ...
}
OnPhotonInstantiate Called on all scripts on a GameObject(and it’s children) that have been spawned using
PhotonNetwork.Instantiate Example: void OnPhotonInstantiate(PhotonMessageInfo info){ ... }
OnPhotonMaxCccuReached Because the concurrent user limit was (temporarily) reached, this client is re-
jected by the server and disconnecting. When this happens, the user might try again later. You can’t
create or join rooms in OnPhotonMaxCcuReached(), cause the client will be disconnecting. You can raise
the CCU limits with a new license (when you host yourself) or extended subscription (when using the
Photon Cloud). The Photon Cloud will mail you when the CCU limit was reached. This is also visible in
the Dashboard (webpage). Example: void OnPhotonMaxCccuReached(){ ... }
OnPhotonCustomRoomPropertiesChanged Called when inside a room when its custom properties have
changed. This is ALSO called for room property changes by the local players. Example: void OnPhoton-
CustomRoomPropertiesChanged(){ ... }
OnPhotonPlayerPropertiesChanged Called when inside a room when a players custom properties change.
Example: void OnPhotonPlayerPropertiesChanged(PhotonPlayer player){ ... }
OnUpdatedFriendList Called when the server sent the response to a FindFriends request and updated
PhotonNetwork.Friends. Example: void OnUpdatedFriendList(){ ... }
OnCustomAuthenticationFailed Called when the custom authentication failed (due to user-input, bad to-
kens/secrets or wrong configuration). Followed by disconnect! Example: void OnCustomAuthentication-
Failed(string debugMessage){ ... } Unless you setup a custom authentication service for your app (in
the Dashboard), this won’t be called! If authentication is successful, this method is also not called but
OnJoinedLobby, OnConnectedToMaster will be called (just as usual).
Enum of "target" options for RPCs. These define which remote clients get your RPC call.
Enumerator
All
Others
MasterClient
AllBuffered
OthersBuffered
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 12
Namespace Documentation
Classes
• class MonoBehaviour
This class adds the property photonView, while logging a warning when your game still uses the networkView.
36 Namespace Documentation
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 13
Class Documentation
Class for constants. These (byte) values define "well known" properties for an Actor / Player. Pun uses these
constants internally.
Public Attributes
Class for constants. These (byte) values define "well known" properties for an Actor / Player. Pun uses these
constants internally.
"Custom properties" have to use a string-type as key. They can be assigned at will.
Container for "Custom Authentication" values in Photon (default: user and token). Set AuthParameters before
connecting - all else is handled.
Public Attributes
Properties
Container for "Custom Authentication" values in Photon (default: user and token). Set AuthParameters before
connecting - all else is handled.
Custom Authentication lets you verify end-users by some kind of login or token. It sends those values to Photon
which will verify them before granting access or disconnecting the client.
The Photon Cloud Dashboard will let you enable this feature and set important server values for it. https-
://cloud.exitgames.com/dashboard
Creates the default parameter string from a user and token value, escaping both. Alternatively set AuthParameters
yourself.
The default parameter string is: "username={user}&token={token}"
Parameters
user Name or other end-user ID used in custom authentication service.
token Token provided by authentication service to be used on initial "login" to Photon.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.3 ErrorCode Class Reference 39
Parameters
byteData Binary token / auth-data to pass on. Empty string will set AuthPostData to null.
This string must contain any (http get) parameters expected by the used authentication service. By default, user-
name and token.
Standard http get parameters are used here and passed on to the service that’s defined in the server (Photon Cloud
Dashboard).
The type of custom authentication provider that should be used. Currently only "Custom" or "None" (turns this off).
After initial authentication, Photon provides a secret for this client / user, which is subsequently used as (cached)
validation.
Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters).
The documentation for this class was generated from the following file:
Class for constants. These (int) values represent error codes, as defined and sent by the Photon LoadBalancing
logic. Pun uses these constants internally.
Public Attributes
• const int Ok = 0
(0) is always "OK", anything else an error or specific situation.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
40 Class Documentation
Class for constants. These (int) values represent error codes, as defined and sent by the Photon LoadBalancing
logic. Pun uses these constants internally.
Codes from the Photon Core are negative. Default-app error codes go down from short.max.
(32755) Custom Authentication of the user failed due to setup reasons (see Cloud Dashboard) or the provided user
data (like username or token). Check error message for details.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.3 ErrorCode Class Reference 41
(32758) Join can fail if the room (name) is not existing (anymore). This can happen when players leave while you
join.
(32765) Game is full. This rarely happens when some player joined the room before your join completed.
(32766) GameId (name) already in use (can’t create another). Change name.
(-1) Something went wrong in the server. Try to reproduce and contact Exit Games.
(32767) Authentication failed. Possible cause: AppId is unknown to Photon (in cloud service).
(-2) The operation you called is not implemented on the server (application) you connect to. Make sure you run the
fitting applications.
(32756) Authorization on the Photon Cloud failed because the app’s subscription does not allow to use a particular
region’s server.
Some subscription plans for the Photon Cloud are region-bound. Servers of other regions can’t be used then.
Check your master server address and compare it with your Photon Cloud Dashboard’s info. https://cloud.-
exitgames.com/dashboard
OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen. Self-hosted Photon
servers with a CCU limited license won’t let a client connect at all.
(32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit of the app’s subscription
is reached.
Unless you have a plan with "CCU Burst", clients might fail the authentication step during connect. Affected client are
unable to call operations. Please note that players who end a game and return to the master server will disconnect
and re-connect, which means that they just played and are rejected in the next minute / re-connect. This is a
temporary measure. Once the CCU is below the limit, players will be able to connect an play again.
OpAuthorize is part of connection workflow but only on the Photon Cloud, this error can happen. Self-hosted Photon
servers with a CCU limited license won’t let a client connect at all.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
42 Class Documentation
(32760) Random matchmaking only succeeds if a room exists thats neither closed nor full. Repeat in a few seconds
or create a new room.
(-3) Operation can’t be executed yet (e.g. OpJoin can’t be called before being authenticated, RaiseEvent cant be
used before getting into a room).
Before you call any operations on the Cloud servers, the automated client workflow must complete its authorization.
In PUN, wait until State is: JoinedLobby (with AutoJoinLobby = true) or ConnectedToMaster (AutoJoinLobby = false)
Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses these constants
internally.
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.4 EventCode Class Reference 43
Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses these constants
internally.
They start at 255 and go DOWN. Your own in-game events can start at 0.
(226) Event with stats about this application (players, rooms, etc)
(229) Update of RoomInfos to be merged into "initial" list (in lobby on Master)
(255) Event Join: someone joined the game. The new actorNumber is provided as well as the properties of that
actor (if set in OpJoin).
(254) Event Leave: The player who left the game can be identified by the actorNumber.
(253) When you call OpSetProperties with the broadcast option "on", this event is fired. It contains the properties
being set.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
44 Class Documentation
(253) When you call OpSetProperties with the broadcast option "on", this event is fired. It contains the properties
being set.
The documentation for this class was generated from the following file:
This static class defines some useful extension methods for several existing classes (e.g. Vector3, float and others).
This static class defines some useful extension methods for several existing classes (e.g. Vector3, float and others).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.5 Extensions Class Reference 45
13.5.2.1 static bool Extensions.AlmostEquals ( this Vector3 target, Vector3 second, float sqrMagnitudePrecision )
[static]
13.5.2.2 static bool Extensions.AlmostEquals ( this Vector2 target, Vector2 second, float sqrMagnitudePrecision )
[static]
13.5.2.3 static bool Extensions.AlmostEquals ( this Quaternion target, Quaternion second, float maxAngle ) [static]
compares the angle between target and second to given float value
13.5.2.4 static bool Extensions.AlmostEquals ( this float target, float second, float floatDiff ) [static]
compares two floats and returns true of their difference is less than floatDiff
Returns
13.5.2.8 static void Extensions.Merge ( this IDictionary target, IDictionary addHash ) [static]
Merges all keys from addHash into the target. Adds new keys and updates the values of existing keys in target.
Parameters
target The IDictionary to update.
addHash The IDictionary containing data to merge into target.
13.5.2.9 static void Extensions.MergeStringKeys ( this IDictionary target, IDictionary addHash ) [static]
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
46 Class Documentation
Parameters
target The target IDicitionary passed in plus all string-typed keys from the addHash.
addHash A IDictionary that should be merged partly into target to update it.
This removes all key-value pairs that have a null-reference as value. Photon properties are removed by setting their
value to null. Changes the original passed IDictionary!
Parameters
original The IDictionary to strip of keys with null-values.
This method copies all string-typed keys of the original into a new Hashtable.
Does not recurse (!) into hashes that might be values in the root-hash. This does not modify the original.
Parameters
original The original IDictonary to get string-typed keys from.
Returns
Returns a string-representation of the IDictionary’s content, inlcuding type-information. Note: This might turn out a
"heavy-duty" call if used frequently but it’s usfuly to debug Dictionary or Hashtable content.
Parameters
origin Some Dictionary or Hashtable.
Returns
The documentation for this class was generated from the following file:
Used to store info about a friend’s online state and in which room he/she is.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.7 GameProperties Class Reference 47
Properties
Used to store info about a friend’s online state and in which room he/she is.
The documentation for this class was generated from the following file:
Class for constants. These (byte) values are for "well known" room/game properties used in Photon Loadbalancing.
Pun uses these constants internally.
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
48 Class Documentation
Class for constants. These (byte) values are for "well known" room/game properties used in Photon Loadbalancing.
Pun uses these constants internally.
"Custom properties" have to use a string-type as key. They can be assigned at will.
(255) Max number of players that "fit" into this room. 0 is for "unlimited".
(252) Current count of players in the room. Used only in the lobby on master.
(250) A list of the room properties to pass to the RoomInfo list in a lobby. This is used in CreateRoom, which defines
this list once per room.
(251) True if the room is to be removed from room listing (used in update to room list in lobby on master)
The documentation for this class was generated from the following file:
This class adds the property photonView, while logging a warning when your game still uses the networkView.
Inheritance diagram for Photon.MonoBehaviour:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.9 OperationCode Class Reference 49
MonoBehaviour
Photon.MonoBehaviour
PhotonView
Properties
This class adds the property photonView, while logging a warning when your game still uses the networkView.
The documentation for this class was generated from the following file:
Class for constants. Contains operation codes. Pun uses these constants internally.
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
50 Class Documentation
Class for constants. Contains operation codes. Pun uses these constants internally.
(248) Operation code to change interest groups in Rooms (Lite application and extending ones).
(222) Request the rooms and online status for a list of friends (by name, which should be unique).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.10 ParameterCode Class Reference 51
Class for constants. Codes for parameters of Operations and Events. Pun uses these constants internally.
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
52 Class Documentation
(255) Code for the gameId/roomName (a unique name per room). Used in OpJoin and similar.
• const byte Broadcast = (byte)LiteOpKey.Broadcast
(250) Code for broadcast parameter of OpSetProperties method.
• const byte ActorList = (byte)LiteOpKey.ActorList
(252) Code for list of players in a room. Currently not used.
• const byte ActorNr = (byte)LiteOpKey.ActorNr
(254) Code of the Actor of an operation. Used for property get and set.
• const byte PlayerProperties = (byte)LiteOpKey.ActorProperties
(249) Code for property set (Hashtable).
• const byte CustomEventContent = (byte)LiteOpKey.Data
(245) Code of data/custom content of an event. Used in OpRaiseEvent.
• const byte Data = (byte)LiteOpKey.Data
(245) Code of data of an event. Used in OpRaiseEvent.
• const byte Code = (byte)LiteOpKey.Code
(244) Code used when sending some code-related parameter, like OpRaiseEvent’s event-code.
• const byte GameProperties = (byte)LiteOpKey.GameProperties
(248) Code for property set (Hashtable).
• const byte Properties = (byte)LiteOpKey.Properties
(251) Code for property-set (Hashtable). This key is used when sending only one set of properties. If either Actor-
Properties or GameProperties are used (or both), check those keys.
• const byte TargetActorNr = (byte)LiteOpKey.TargetActorNr
(253) Code of the target Actor of an operation. Used for property set. Is 0 for game
• const byte ReceiverGroup = (byte)LiteOpKey.ReceiverGroup
(246) Code to select the receivers of events (used in Lite, Operation RaiseEvent).
• const byte Cache = (byte)LiteOpKey.Cache
(247) Code for caching events while raising them.
• const byte CleanupCacheOnLeave = (byte)241
(241) Bool parameter of CreateGame Operation. If true, server cleans up roomcache of leaving players (their cached
events get removed).
• const byte Group = LiteOpKey.Group
(240) Code for "group" operation-parameter (as used in Op RaiseEvent).
• const byte Remove = LiteOpKey.Remove
(239) The "Remove" operation-parameter can be used to remove something from a list. E.g. remove groups from
player’s interest groups.
• const byte Add = LiteOpKey.Add
(238) The "Add" operation-parameter can be used to add something to some list or set. E.g. add groups to player’s
interest groups.
• const byte ClientAuthenticationType = 217
(217) This key’s (byte) value defines the target custom authentication type/service the client connects with. Used in
OpAuthenticate
• const byte ClientAuthenticationParams = 216
(216) This key’s (string) value provides parameters sent to the custom authentication type/service the client connects
with. Used in OpAuthenticate
• const byte CreateIfNotExists = 215
(215) Makes the server create a room if it doesn’t exist. OpJoin uses this to always enter a room, unless it exists and
is full/closed.
• const byte ClientAuthenticationData = 214
(214) This key’s (string or byte[]) value provides parameters sent to the custom authentication service setup in Photon
Dashboard. Used in OpAuthenticate
• const byte FindFriendsRequestList = (byte)1
(1) Used in Op FindFriends request. Value must be string[] of friends to look up.
• const byte FindFriendsResponseOnlineList = (byte)1
(1) Used in Op FindFriends response. Contains bool[] list of online states (false if not online).
• const byte FindFriendsResponseRoomIdList = (byte)2
(2) Used in Op FindFriends response. Contains string[] of room names ("" where not known or no room joined).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.10 ParameterCode Class Reference 53
Class for constants. Codes for parameters of Operations and Events. Pun uses these constants internally.
(254) Code of the Actor of an operation. Used for property get and set.
(238) The "Add" operation-parameter can be used to add something to some list or set. E.g. add groups to player’s
interest groups.
(224) Your application’s ID: a name on your own Photon or a GUID on the Photon Cloud
(241) Bool parameter of CreateGame Operation. If true, server cleans up roomcache of leaving players (their
cached events get removed).
(214) This key’s (string or byte[]) value provides parameters sent to the custom authentication service setup in
Photon Dashboard. Used in OpAuthenticate
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
54 Class Documentation
(216) This key’s (string) value provides parameters sent to the custom authentication type/service the client connects
with. Used in OpAuthenticate
(217) This key’s (byte) value defines the target custom authentication type/service the client connects with. Used in
OpAuthenticate
(244) Code used when sending some code-related parameter, like OpRaiseEvent’s event-code.
This is not the same as the Operation’s code, which is no longer sent as part of the parameter Dictionary in Photon
3.
(215) Makes the server create a room if it doesn’t exist. OpJoin uses this to always enter a room, unless it exists
and is full/closed.
(1) Used in Op FindFriends request. Value must be string[] of friends to look up.
(1) Used in Op FindFriends response. Contains bool[] list of online states (false if not online).
(2) Used in Op FindFriends response. Contains string[] of room names ("" where not known or no room joined).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.10 ParameterCode Class Reference 55
(227) Count of players on the master server (connected to master server for this application, looking for games,
used in stats event)
(223) Modifies the matchmaking algorithm used for OpJoinRandom. Allowed parameter values are defined in enum
MatchmakingMode.
(229) Count of players in rooms (connected to game servers for this application, used in stats event)
(223) Not used (as "Position" currently). If you get queued before connect, this is your position
(251) Code for property-set (Hashtable). This key is used when sending only one set of properties. If either Actor-
Properties or GameProperties are used (or both), check those keys.
(246) Code to select the receivers of events (used in Lite, Operation RaiseEvent).
(239) The "Remove" operation-parameter can be used to remove something from a list. E.g. remove groups from
player’s interest groups.
(255) Code for the gameId/roomName (a unique name per room). Used in OpJoin and similar.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
56 Class Documentation
(253) Code of the target Actor of an operation. Used for property set. Is 0 for game
(225) User’s ID
The documentation for this class was generated from the following file:
• PBitStream ()
• PBitStream (int bitCount)
• PBitStream (IEnumerable< byte > bytes, int bitCount)
• void Add (bool val)
• byte[ ] ToBytes ()
• bool GetNext ()
• bool Get (int bitIndex)
• void Set (int bitIndex, bool value)
Properties
13.11.1.1 PBitStream.PBitStream ( )
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.12 PhotonLagSimulationGui Class Reference 57
The documentation for this class was generated from the following file:
This MonoBehaviour is a basic GUI for the Photon client’s network-simulation feature. It can modify lag (fixed delay),
jitter (random lag) and packet loss.
Inheritance diagram for PhotonLagSimulationGui:
MonoBehaviour
PhotonLagSimulationGui
• void Start ()
• void OnGUI ()
Public Attributes
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
58 Class Documentation
This MonoBehaviour is a basic GUI for the Photon client’s network-simulation feature. It can modify lag (fixed delay),
jitter (random lag) and packet loss.
• PhotonMessageInfo ()
Initializes a new instance of the PhotonMessageInfo class. To create an empty messageinfo only!
• PhotonMessageInfo (PhotonPlayer player, int timestamp, PhotonView view)
• override string ToString ()
Public Attributes
• PhotonPlayer sender
• PhotonView photonView
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 59
Properties
13.13.2.1 PhotonMessageInfo.PhotonMessageInfo ( )
Initializes a new instance of the PhotonMessageInfo class. To create an empty messageinfo only!
The documentation for this class was generated from the following file:
The main class to use the PhotonNetwork plugin. This class is static.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
60 Class Documentation
Connect to the configured Photon server: Reads PhotonNetwork.serverSettingsAssetPath and connects to cloud or
your own server.
• static void ConnectToBestCloudServer (string gameVersion)
Connect to the Photon Cloud region with the lowest ping (on platforms that support Unity’s Ping).
• static void OverrideBestCloudServer (CloudServerRegion region)
Overwrites the region that is used for ConnectToBestCloudServer(string gameVersion) This will overwrite the result
that was gotten by pinging all cloud servers.
• static void RefreshCloudServerRating ()
Pings all cloud servers again to find the one with best ping (currently).
• static void Connect (string serverAddress, int port, string appID, string gameVersion)
Connect to the Photon server by address, port, appID and game(client) version.
• static void Disconnect ()
Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFrom-
Photon on completion.
• static void InitializeSecurity ()
Used for compatibility with Unity networking only. Encryption is automatically initialized while connecting.
• static bool FindFriends (string[ ] friendsToFind)
Request the rooms and online status for a list of friends. All client must set a unique username via PlayerName
property. The result is available in this.Friends.
• static void CreateRoom (string roomName)
Creates a room with given name but fails if this room is existing already.
• static void CreateRoom (string roomName, bool isVisible, bool isOpen, int maxPlayers)
Creates a room with given name but fails if this room is existing already.
• static void CreateRoom (string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable custom-
RoomProperties, string[ ] propsToListInLobby)
Creates a room with given name but fails if this room is existing already.
• static void JoinRoom (string roomName)
Join room by roomname and on success calls OnJoinedRoom().
• static void JoinRoom (string roomName, bool createIfNotExists)
Join room by roomName with an option to create it on the fly if not existing.
• static void JoinRandomRoom ()
Joins any available room but will fail if none is currently available.
• static void JoinRandomRoom (Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers)
Attempts to join an open room with fitting, custom properties but fails if none is currently available.
• static void JoinRandomRoom (Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers,
MatchmakingMode matchingType)
Attempts to join an open room with fitting, custom properties but fails if none is currently available.
• static void LeaveRoom ()
Leave the current room
• static RoomInfo[ ] GetRoomList ()
Gets an array of (currently) known rooms as RoomInfo. This list is automatically updated every few seconds while
this client is in the lobby (on the Master Server). Not available while being in a room.
• static void SetPlayerCustomProperties (Hashtable customProperties)
Sets this (local) player’s properties. This caches the properties in PhotonNetwork.player.customProperties. Create-
Room, JoinRoom and JoinRandomRoom will all apply your player’s custom properties when you enter the room.
While in a room, your properties are synced with the other players. If the Hashtable is null, the custom properties
will be cleared. Custom properties are never cleared automatically, so they carry over to the next room, if you don’t
change them.
• static int AllocateViewID ()
Allocates a viewID that’s valid for the current/local player.
• static void UnAllocateViewID (int viewID)
Unregister a viewID (of manually instantiated and destroyed networked objects).
• static GameObject Instantiate (string prefabName, Vector3 position, Quaternion rotation, int group)
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 61
Instantiate a prefab over the network. This prefab needs to be located in the root of a "Resources" folder.
• static GameObject Instantiate (string prefabName, Vector3 position, Quaternion rotation, int group, object[ ]
data)
Instantiate a prefab over the network. This prefab needs to be located in the root of a "Resources" folder.
• static GameObject InstantiateSceneObject (string prefabName, Vector3 position, Quaternion rotation, int
group, object[ ] data)
Instantiate a scene-owned prefab over the network. The PhotonViews will be controllable by the MasterClient. This
prefab needs to be located in the root of a "Resources" folder.
• static int GetPing ()
The current roundtrip time to the photon server
• static void FetchServerTimestamp ()
Refreshes the server timestamp (async operation, takes a roundtrip).
• static void SendOutgoingCommands ()
Can be used to immediately send the RPCs and Instantiates just made, so they are on their way to the other players.
• static void CloseConnection (PhotonPlayer kickPlayer)
Request a client to disconnect (KICK). Only the master client can do this.
• static void Destroy (PhotonView targetView)
Network-Destroy the GameObject associated with the PhotonView, unless the PhotonView is static or not under this
client’s control.
• static void Destroy (GameObject targetGo)
Network-Destroy the GameObject, unless it is static or not under this client’s control.
• static void DestroyPlayerObjects (PhotonPlayer targetPlayer)
Network-Destroy all GameObjects, PhotonViews and their RPCs of targetPlayer. Can only be called on local player
(for "self") or Master Client (for anyone).
• static void DestroyPlayerObjects (int targetPlayerId)
Network-Destroy all GameObjects, PhotonViews and their RPCs of this player (by ID). Can only be called on local
player (for "self") or Master Client (for anyone).
• static void DestroyAll ()
Network-Destroy all GameObjects, PhotonViews and their RPCs in the room. Removes anything buffered from the
server. Can only be called by Master Client (for anyone).
• static void RemoveRPCs (PhotonPlayer targetPlayer)
Remove all buffered RPCs from server that were sent by targetPlayer. Can only be called on local player (for "self")
or Master Client (for anyone).
• static void RemoveRPCs (PhotonView targetPhotonView)
Remove all buffered RPCs from server that were sent via targetPhotonView. The Master Client and the owner of the
targetPhotonView may call this.
• static void RemoveRPCsInGroup (int targetGroup)
Remove all buffered RPCs from server that were sent in the targetGroup, if this is the Master Client or if this controls
the individual PhotonView.
• static void SetReceivingEnabled (int group, bool enabled)
Enable/disable receiving on given group (applied to PhotonViews)
• static void SetSendingEnabled (int group, bool enabled)
Enable/disable sending on given group (applied to PhotonViews)
• static void SetLevelPrefix (short prefix)
Sets level prefix for PhotonViews instantiated later on. Don’t set it if you need only one!
• static void LoadLevel (int levelNumber)
Loads the level and automatically pauses the network queue. Call this in OnJoinedRoom to make sure no cached
RPCs are fired in the wrong scene.
• static void LoadLevel (string levelTitle)
Loads the level and automatically pauses the network queue. Call this in OnJoinedRoom to make sure no cached
RPCs are fired in the wrong scene.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
62 Class Documentation
Public Attributes
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 63
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
64 Class Documentation
The count of players currently looking for a room. This is updated on the MasterServer (only) in 5sec intervals (if any
count changed).
• static int countOfPlayersInRooms [get]
The count of players currently inside a room This is updated on the MasterServer (only) in 5sec intervals (if any count
changed).
• static int countOfPlayers [get]
The count of players currently using this application. This is updated on the MasterServer (only) in 5sec intervals (if
any count changed).
• static int countOfRooms [get]
The count of rooms currently in use. When inside the lobby this is based on PhotonNetwork.GetRoomList().Length.
When not inside the lobby, this value updated on the MasterServer (only) in 5sec intervals (if any count changed).
• static bool NetworkStatisticsEnabled [get, set]
Enables or disables the collection of statistics about this client’s traffic. If you encounter issues with clients, the traffic
stats are a good starting point to find solutions.
• static int ResentReliableCommands [get]
Count of commands that got repeated (due to local repeat-timing before an ACK was received).
The main class to use the PhotonNetwork plugin. This class is static.
Returns
Request a client to disconnect (KICK). Only the master client can do this.
Parameters
kickPlayer The PhotonPlayer to kick.
13.14.2.3 static void PhotonNetwork.Connect ( string serverAddress, int port, string appID, string gameVersion )
[static]
Connect to the Photon server by address, port, appID and game(client) version.
This method is used by ConnectUsingSettings and ConnectToBestCloudServer.
To connect to the Photon Cloud, a valid AppId must be in the settings file (shown in the Photon Cloud Dashboard).
https://cloud.exitgames.com/dashboard
Connecting to the Photon Cloud might fail due to:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 65
Parameters
serverAddress The server’s address (either your own or Photon Cloud address).
port The server’s port to connect to.
appID Your application ID (Photon Cloud provides you with a GUID for your game).
gameVersion This client’s version number. Users are separated by gameversion (which allows you to make
breaking changes).
Connect to the Photon Cloud region with the lowest ping (on platforms that support Unity’s Ping).
Will save the result of pinging all cloud servers in PlayerPrefs. Calling this the first time can take +-2 seconds. The
ping result can be overridden via PhotonNetwork.OverrideBestCloudServer(..) This call can take up to 2 seconds if
it is the first time you are using this, all cloud servers will be pinged to check for the best region.
The PUN Setup Wizard stores your appID in a settings file and applies a server address/port. This is used for
Connect(string serverAddress, int port, string appID, string gameVersion).
To connect to the Photon Cloud, a valid AppId must be in the settings file (shown in the Photon Cloud Dashboard).
https://cloud.exitgames.com/dashboard
Connecting to the Photon Cloud might fail due to:
Connect to the configured Photon server: Reads PhotonNetwork.serverSettingsAssetPath and connects to cloud
or your own server.
The PUN Setup Wizard stores your appID in a settings file and applies a server address/port. This is used for
Connect(string serverAddress, int port, string appID, string gameVersion).
To connect to the Photon Cloud, a valid AppId must be in the settings file (shown in the Photon Cloud Dashboard).
https://cloud.exitgames.com/dashboard
Connecting to the Photon Cloud might fail due to:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
66 Class Documentation
Parameters
gameVersion This client’s version number. Users are separated from each other by gameversion (which
allows you to make breaking changes).
Creates a room with given name but fails if this room is existing already.
If you don’t want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a
GUID as string). Call this only on the master server. Internally, the master will respond with a server-address (and
roomName, if needed). Both are used internally to switch to the assigned game server and roomName.
PhotonNetwork.autoCleanUpPlayerObjects will become this room’s AutoCleanUp property and that’s used by all
clients that join this room.
Parameters
roomName Unique name of the room to create.
13.14.2.7 static void PhotonNetwork.CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers )
[static]
Creates a room with given name but fails if this room is existing already.
If you don’t want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a
GUID as string). Call this only on the master server. Internally, the master will respond with a server-address (and
roomName, if needed). Both are used internally to switch to the assigned game server and roomName
Parameters
roomName Unique name of the room to create. Pass null or "" to make the server generate a name.
isVisible Shows (or hides) this room from the lobby’s listing of rooms.
isOpen Allows (or disallows) others to join this room.
maxPlayers Max number of players that can join the room.
13.14.2.8 static void PhotonNetwork.CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers,
Hashtable customRoomProperties, string[ ] propsToListInLobby ) [static]
Creates a room with given name but fails if this room is existing already.
If you don’t want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a
GUID as string). Call this only on the master server. Internally, the master will respond with a server-address (and
roomName, if needed). Both are used internally to switch to the assigned game server and roomName.
PhotonNetwork.autoCleanUpPlayerObjects will become this room’s AutoCleanUp property and that’s used by all
clients that join this room.
Parameters
roomName Unique name of the room to create. Pass null or "" to make the server generate a name.
isVisible Shows (or hides) this room from the lobby’s listing of rooms.
isOpen Allows (or disallows) others to join this room.
maxPlayers Max number of players that can join the room.
customRoom- Custom properties of the new room (set on create, so they are immediately available).
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 67
propsToListIn- Array of custom-property-names that should be forwarded to the lobby (include only the useful
Lobby ones).
Network-Destroy the GameObject associated with the PhotonView, unless the PhotonView is static or not under
this client’s control.
Destroying a networked GameObject includes:
• Removing RPCs buffered for PhotonViews that got created indirectly with the PhotonNetwork.Instantiate call.
• Sending a message to other clients to remove the GameObject also (affected by network lag).
Destroying networked objects works only if they got created with PhotonNetwork.Instantiate(). Objects loaded with
a scene are ignored, no matter if they have PhotonView components.
The GameObject must be under this client’s control:
• Instantiated objects of players who left the room are controlles by the Master Client.
Returns
Network-Destroy the GameObject, unless it is static or not under this client’s control.
Destroying a networked GameObject includes:
• Removing RPCs buffered for PhotonViews that got created indirectly with the PhotonNetwork.Instantiate call.
• Sending a message to other clients to remove the GameObject also (affected by network lag).
Destroying networked objects works only if they got created with PhotonNetwork.Instantiate(). Objects loaded with
a scene are ignored, no matter if they have PhotonView components.
The GameObject must be under this client’s control:
• Instantiated objects of players who left the room are controlles by the Master Client.
Returns
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
68 Class Documentation
Network-Destroy all GameObjects, PhotonViews and their RPCs in the room. Removes anything buffered from the
server. Can only be called by Master Client (for anyone).
Can only be called by Master Client (for anyone). Unlike the Destroy methods, this will remove anything from the
server’s room buffer. If your game buffers anything beyond Instantiate and RPC calls, that will be cleaned as well
from server.
Destroying all includes:
• Remove anything from the server’s room buffer (Instantiate, RPCs, anything buffered).
• Sending a message to other clients to destroy everything locally, too (affected by network lag).
Destroying networked objects works only if they got created with PhotonNetwork.Instantiate(). Objects loaded with
a scene are ignored, no matter if they have PhotonView components.
Returns
Network-Destroy all GameObjects, PhotonViews and their RPCs of targetPlayer. Can only be called on local player
(for "self") or Master Client (for anyone).
Destroying a networked GameObject includes:
• Removing RPCs buffered for PhotonViews that got created indirectly with the PhotonNetwork.Instantiate call.
• Sending a message to other clients to remove the GameObject also (affected by network lag).
Destroying networked objects works only if they got created with PhotonNetwork.Instantiate(). Objects loaded with
a scene are ignored, no matter if they have PhotonView components.
Returns
Network-Destroy all GameObjects, PhotonViews and their RPCs of this player (by ID). Can only be called on local
player (for "self") or Master Client (for anyone).
Destroying a networked GameObject includes:
• Removing RPCs buffered for PhotonViews that got created indirectly with the PhotonNetwork.Instantiate call.
• Sending a message to other clients to remove the GameObject also (affected by network lag).
Destroying networked objects works only if they got created with PhotonNetwork.Instantiate(). Objects loaded with
a scene are ignored, no matter if they have PhotonView components.
Returns
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 69
Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnected-
FromPhoton on completion.
When you disconnect, the client will send a "disconnecting" message to the server. This speeds up leave/disconnect
messages for players in the same room as you (otherwise the server would timeout this client’s connection). When
used in offlineMode, the state-change and event-call OnDisconnectedFromPhoton are immediate. Offline mode is
set to false as well. Once disconnected, the client can connect again. Use ConnectUsingSettings.
Request the rooms and online status for a list of friends. All client must set a unique username via PlayerName
property. The result is available in this.Friends.
Used on Master Server to find the rooms played by a selected list of users. The result will be mapped to Load-
BalancingClient.Friends when available. The list is initialized by OpFindFriends on first use (before that, it is null).
Users identify themselves by setting a PlayerName in the LoadBalancingClient instance. This in turn will send the
name in OpAuthenticate after each connect (to master and game servers). Note: Changing a player’s name doesn’t
make sense when using a friend list.
The list of usernames must be fetched from some other source (not provided by Photon).
Internal: The server response includes 2 arrays of info (each index matching a friend from the request): Parameter-
Code.FindFriendsResponseOnlineList = bool[] of online states ParameterCode.FindFriendsResponseRoomIdList =
string[] of room names (empty string if not in a room)
Parameters
friendsToFind Array of friend’s names (make sure they are unique).
Returns
If the operation could be sent (requires connection, only one request is allowed at any time). Always false in
offline mode.
Returns
Gets an array of (currently) known rooms as RoomInfo. This list is automatically updated every few seconds while
this client is in the lobby (on the Master Server). Not available while being in a room.
Creates a new instance of the list each time called. Copied from networkingPeer.mGameList.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
70 Class Documentation
Returns
Used for compatibility with Unity networking only. Encryption is automatically initialized while connecting.
13.14.2.20 static GameObject PhotonNetwork.Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group
) [static]
Instantiate a prefab over the network. This prefab needs to be located in the root of a "Resources" folder.
Instead of using prefabs in the Resources folder, you can manually Instantiate and assign PhotonViews. See doc.
Parameters
prefabName Name of the prefab to instantiate.
position Position Vector3 to apply on instantiation.
rotation Rotation Quaternion to apply on instantiation.
group The group for this PhotonView.
Returns
13.14.2.21 static GameObject PhotonNetwork.Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int
group, object[ ] data ) [static]
Instantiate a prefab over the network. This prefab needs to be located in the root of a "Resources" folder.
Instead of using prefabs in the Resources folder, you can manually Instantiate and assign PhotonViews. See doc.
Parameters
prefabName Name of the prefab to instantiate.
position Position Vector3 to apply on instantiation.
rotation Rotation Quaternion to apply on instantiation.
group The group for this PhotonView.
data Optional instantiation data. This will be saved to it’s PhotonView.instantiationData.
Returns
Instantiate a scene-owned prefab over the network. The PhotonViews will be controllable by the MasterClient. This
prefab needs to be located in the root of a "Resources" folder.
Only the master client can Instantiate scene objects. Instead of using prefabs in the Resources folder, you can
manually Instantiate and assign PhotonViews. See doc.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 71
Parameters
prefabName Name of the prefab to instantiate.
position Position Vector3 to apply on instantiation.
rotation Rotation Quaternion to apply on instantiation.
group The group for this PhotonView.
data Optional instantiation data. This will be saved to it’s PhotonView.instantiationData.
Returns
Internally used by Editor scripts, called on Hierarchy change (includes scene save) to remove surplus hidden
PhotonHandlers.
Joins any available room but will fail if none is currently available.
If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom). Alterna-
tively, try again in a moment.
Attempts to join an open room with fitting, custom properties but fails if none is currently available.
If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom). Alterna-
tively, try again in a moment.
Parameters
expected- Filters for rooms that match these custom properties (string keys and values). To ignore, pass
CustomRoom- null.
Properties
expectedMax- Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.
Players
Attempts to join an open room with fitting, custom properties but fails if none is currently available.
If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom). Alterna-
tively, try again in a moment.
Parameters
expected- Filters for rooms that match these custom properties (string keys and values). To ignore, pass
CustomRoom- null.
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
72 Class Documentation
expectedMax- Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.
Players
matchingType Selects one of the available matchmaking algorithms. See MatchmakingMode enum for op-
tions.
Join room by roomName with an option to create it on the fly if not existing.
Join will try to enter a room by roomName. If this room is full or closed, this will fail. If the room is not existing,
JoinRoom will also fail by default.
You can set createIfNotExists to true to make the server instantly create the room if it doesn’t exist. This makes it
easier to get into the same room when several players exchanged a roomName already: Any player can try to join
or create the room in one step - it doesn’t matter who’s first.
OnJoinedRoom() gets called if the room existed and was joined, OnCreatedRoom() gets called if the room didn’t
exist and this client created it. OnPhotonJoinRoomFailed() gets called if the room couldn’t be joined or created.
Implement either in any script in the scene to react to joining/creating a room.
To join a room from the lobby’s listing, use RoomInfo.name as roomName here.
PhotonNetworkingMessage.OnPhotonJoinRoomFailed PhotonNetworkingMessage.OnJoinedRoom
Parameters
roomName Unique name of the room to join (or create if createIfNotExists is true).
createIfNotExists If true, the server will attempt to create a room, making the success callback OnCreated-
Room().
Loads the level and automatically pauses the network queue. Call this in OnJoinedRoom to make sure no cached
RPCs are fired in the wrong scene.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 73
Parameters
levelNumber Number of the level to load (make sure it’s in the build preferences).
Loads the level and automatically pauses the network queue. Call this in OnJoinedRoom to make sure no cached
RPCs are fired in the wrong scene.
Parameters
levelTitle Name of the level to load.
Returns
Overwrites the region that is used for ConnectToBestCloudServer(string gameVersion) This will overwrite the result
that was gotten by pinging all cloud servers.
Use this to allow your users to specify their region manually.
Pings all cloud servers again to find the one with best ping (currently).
Remove all buffered RPCs from server that were sent by targetPlayer. Can only be called on local player (for "self")
or Master Client (for anyone).
This method requires either:
• This client is the Master Client (can remove any PhotonPlayer’s RPCs).
If the targetPlayer calls RPCs at the same time that this is called, network lag will determine if those get buffered or
cleared like the rest.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
74 Class Documentation
Parameters
targetPlayer This player’s buffered RPCs get removed from server buffer.
Remove all buffered RPCs from server that were sent via targetPhotonView. The Master Client and the owner of
the targetPhotonView may call this.
This method requires either:
• This client is the Master Client (can remove any PhotonView’s RPCs).
Parameters
targetPhoton- RPCs buffered for this PhotonView get removed from server buffer.
View
Remove all buffered RPCs from server that were sent in the targetGroup, if this is the Master Client or if this controls
the individual PhotonView.
This method requires either:
• This client is the Master Client (can remove any RPCs per group).
• Any other client: each PhotonView is checked if it is under this client’s control. Only those RPCs are removed.
Parameters
targetGroup Interest group that gets all RPCs removed.
Can be used to immediately send the RPCs and Instantiates just made, so they are on their way to the other players.
This could be useful if you do a RPC to load a level and then load it yourself. While loading, no RPCs are sent to
others, so this would delay the "load" RPC. You can send the RPC to "others", use this method, disable the message
queue (by isMessageQueueRunning) and then load.
Sets level prefix for PhotonViews instantiated later on. Don’t set it if you need only one!
Important: If you don’t use multiple level prefixes, simply don’t set this value. The default value is optimized out of
the traffic.
This won’t affect existing PhotonViews (they can’t be changed yet for existing PhotonViews).
Messages sent with a different level prefix will be received but not executed. This affects RPCs, Instantiates and
synchronization.
Be aware that PUN never resets this value, you’ll have to do so yourself.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 75
Parameters
prefix Max value is short.MaxValue = 32767
Allows the current Master Client to assign someone else as MC - custom selection should pick the same user on
any client.
The ReceiverGroup.MasterClient (usable in RPCs) is not affected by this (still points to lowest player.ID in room).
Avoid using this enum value (and send to a specific player instead).
If the current Master Client leaves, PUN will detect a new one by "lowest player ID". Implement OnMasterClient-
Switched to get a callback in this case. The PUN-selected Master Client might assign a new one.
Make sure you don’t create an endless loop of Master-assigning! When selecting a custom Master Client, all clients
should point to the same player, no matter who actually assigns this player.
Locally the Master Client is immediately switched, while remote clients get an event. This means the game is
tempoarily without Master Client like when a current Master Client leaves.
When switching the Master Client manually, keep in mind that this user might leave and not do it’s work, just like any
Master Client.
Parameters
playerId The player.ID of the next Master Client.
Returns
False when this synced action couldn’t be done. Must be online and Master Client.
Sets this (local) player’s properties. This caches the properties in PhotonNetwork.player.customProperties. Create-
Room, JoinRoom and JoinRandomRoom will all apply your player’s custom properties when you enter the room.
While in a room, your properties are synced with the other players. If the Hashtable is null, the custom properties
will be cleared. Custom properties are never cleared automatically, so they carry over to the next room, if you don’t
change them.
Don’t set properties by modifying PhotonNetwork.player.customProperties!
Parameters
custom- Only string-typed keys will be used from this hashtable. If null, custom properties are all
Properties deleted.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
76 Class Documentation
Parameters
group The interest group to affect.
enabled Sets if sending to group is enabled (or not).
The maximum amount of assigned PhotonViews PER player (or scene). See the documentation on how to raise
this limitation
Serialized server settings, written by the Setup Wizard for use in ConnectUsingSettings.
The minimum difference between floats before we send it via a PhotonView’s OnSerialize/ObservingComponent
The minimum angle that a rotation needs to change before we send it via a PhotonView’s OnSerialize/Observing-
Component
The minimum difference that a Vector2 or Vector3(e.g. a transforms rotation) needs to change before we send it via
a PhotonView’s OnSerialize/ObservingComponent Note that this is the sqrMagnitude. E.g. to send only after a 0.01
change on the Y-axix, we use 0.01f∗0.01f=0.0001f. As a remedy against float inaccuracy we use 0.000099f instead
of 0.0001f.
Keeps references to GameObjects for frequent instantiation (out of memory instead of loading the Resources).
You should be able to modify the cache anytime you like, except while Instantiate is used. Best do it only in the
main-Thread.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 77
If not null, this is the (exclusive) list of GameObjects that get called by PUN SendMonoMessage().
For all callbacks defined in PhotonNetworkingMessage, PUN will use SendMonoMessage and call FindObjectsOf-
Type() to find all scripts and GameObjects that might want a callback by PUN.
PUN callbacks are not very frequent (in-game, property updates are most frequent) but FindObjectsOfType is time
consuming and with a large number of GameObjects, performance might suffer.
Optionally, SendMonoMessageTargets can be used to supply a list of target GameObjects. This skips the Find-
ObjectsOfType() but any GameObject that needs callbacks will have to Add itself to this list.
If null, the default behaviour is to do a SendMessage on each GameObject with a MonoBehaviour.
Name of the PhotonServerSettings file (used to load and by PhotonEditor to save new files).
While enabled (true), Instantiate uses PhotonNetwork.PrefabCache to keep game objects in memory (improving
instantiation of the same prefab).
Setting UsePrefabCache to false during runtime will not clear PrefabCache but will ignore it right away. You could
clean and modify the cache yourself. Read its comments.
Version number of PUN. Also used in GameVersion to separate client version from each other.
A user’s authentication values used during connect for Custom Authentication with Photon (and a custom ser-
vice/community). Set these before calling Connect if you want custom authentication.
If authentication fails for any values, PUN will call your implementation of OnCustomAuthenticationFailed(string
debugMsg). See: PhotonNetworkingMessage.OnCustomAuthenticationFailed
This setting defines if players in a room should destroy a leaving player’s instantiated GameObjects and Photon-
Views.
When "this client" creates a room/game, autoCleanUpPlayerObjects is copied to that room’s properties and used
by all PUN clients in that room (no matter what their autoCleanUpPlayerObjects value is).
If room.AutoCleanUp is enabled in a room, the PUN clients will destroy a player’s objects on leave.
When enabled, the server will clean RPCs, instantiated GameObjects and PhotonViews of the leaving player and
joining players won’t get those at anymore.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
78 Class Documentation
Defines if the PhotonNetwork should join the "lobby" when connected to the Master server. If this is false, On-
ConnectedToMaster() will be called when connection to the Master is available. OnJoinedLobby() will NOT be
called if this is false.
Enabled by default.
The room listing will not become available. Rooms can be created and joined (randomly) without joining the lobby
(and getting sent the room list).
If true, PUN will make sure that all users are in the same scene at all times. If the MasterClient switches, all clients
will load the new scene. This also takes care of smooth loading of the game scene after joining a game from your
main menu.
true if automatically sync scene; otherwise, false.
Detailed connection state (ignorant of PUN, so it can be "disconnected" while switching servers).
The count of players currently using this application. This is updated on the MasterServer (only) in 5sec intervals (if
any count changed).
The count of players currently inside a room This is updated on the MasterServer (only) in 5sec intervals (if any
count changed).
The count of players currently looking for a room. This is updated on the MasterServer (only) in 5sec intervals (if
any count changed).
The count of rooms currently in use. When inside the lobby this is based on PhotonNetwork.GetRoomList().Length.
When not inside the lobby, this value updated on the MasterServer (only) in 5sec intervals (if any count changed).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 79
Read-only list of friends, their online status and the room they are in. Null until initialized by a FindFriends call.
Do not modify this list! It’s internally handles by FindFriends and only useful to read the values. The value of
FriendsListAge tells you how old the data is in milliseconds.
Don’t get this list more often than useful (> 10 seconds). In best case, keep the list you fetch really short. You could
(e.g.) get the full list only once, then request a few updates only for friends who are online. After a while (e.g. 1
minute), you can get the full list again (to update online states).
Age of friend list info (in milliseconds). It’s 0 until a friend list is fetched.
Returns true when we are connected to Photon and in the lobby state
Can be used to pause dispatching of incoming evtents (RPCs, Instantiates and anything else incoming).
While IsMessageQueueRunning == false, the OnPhotonSerializeView calls are not done and nothing is sent by a
client. Also, incoming messages will be queued until you re-activate the message queue.
This can be useful if you first want to load a level, then go on receiving data of PhotonViews and RPCs. The client
will go on receiving and sending acknowledgements for incoming packages and your RPCs/Events. This adds "lag"
and can cause issues when the pause is longer, as all incoming messages are just queued.
The PhotonPlayer of the master client. The master client is the ’virtual owner’ of the room. You can use it if you
need authorative decision made by one of the players.
The masterClient is null until a room is joined and becomes null again when the room is left.
The maximum number of players for a room. Better: Set it in CreateRoom. If no room is opened, this will return 0.
Enables or disables the collection of statistics about this client’s traffic. If you encounter issues with clients, the
traffic stats are a good starting point to find solutions.
Only with enabled stats, you can use GetVitalStats
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
80 Class Documentation
Offline mode can be set to re-use your multiplayer code in singleplayer game modes. When this is on Photon-
Network will not create any connections and there is near to no overhead. Mostly usefull for reusing RPC’s and
PhotonNetwork.Instantiate
The local PhotonPlayer. Always available and represents this player. CustomProperties can be set before entering
a room and will be synced as well.
Count of commands that got repeated (due to local repeat-timing before an ACK was received).
Get the room we’re currently in. Null if we aren’t in any room.
Defines how many times per second PhotonNetwork should send a package. If you change this, do not forget to
also change ’sendRateOnSerialize’.
Less packages are less overhead but more delay. Setting the sendRate to 50 will create up to 50 packages per
second (which is a lot!). Keep your target platform in mind: mobile networks are slower and less reliable.
Defines how many times per second OnPhotonSerialize should be called on PhotonViews.
Choose this value in relation to ’sendRate’. OnPhotonSerialize will creart the commands to be put into packages. A
lower rate takes up less performance but will cause more lag.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.15 PhotonPlayer Class Reference 81
Used once per dispatch to limit unreliable commands per channel (so after a pause, many channels can still cause
a lot of unreliable commands)
The documentation for this class was generated from the following file:
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
82 Class Documentation
Properties
• int ID [get]
This player’s actorID
• string name [get, set]
Nickname of this player.
• bool isMasterClient [get]
The player with the lowest actorID is the master and could be used for special tasks.
• Hashtable customProperties [get, set]
Read-only cache for custom properties of player. Set via Player.SetCustomProperties.
• Hashtable allProperties [get]
Creates a Hashtable with all properties (custom and "well known" ones).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.15 PhotonPlayer Class Reference 83
ID ActorID
Returns
The player with matching actorID or null, if the actorID is not in use.
Updates and synchronizes the named properties of this Player with the values of propertiesToSet.
Any player’s properties are available in a Room only and only until the player disconnect or leaves. Access any
player’s properties by: Player.CustomProperties (read-only!) but don’t modify that hashtable.
New properties are added, existing values are updated. Other values will not be changed, so only provide values
that changed or are new. To delete a named (custom) property of this player, use null as value. Only string-typed
keys are applied (everything else is ignored).
Local cache is updated immediately, other players are updated through Photon with a fitting operation. To reduce
network traffic, set only values that actually changed.
Parameters
propertiesToSet Hashtable of props to udpate, set and sync. See description.
Only one player is controlled by each client. Others are not local.
Creates a Hashtable with all properties (custom and "well known" ones).
If used more often, this should be cached.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
84 Class Documentation
The player with the lowest actorID is the master and could be used for special tasks.
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.
Inheritance diagram for PhotonStatsGui:
MonoBehaviour
PhotonStatsGui
• void Start ()
• void Update ()
Checks for shift+tab input combination (to toggle statsOn).
• void OnGUI ()
• void TrafficStatsWindow (int windowID)
Public Attributes
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.16 PhotonStatsGui Class Reference 85
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.
The shown health values can help identify problems with connection losses or performance. Example: If the time
delta between two consecutive SendOutgoingCommands calls is a second or more, chances rise for a disconnect
being caused by this (because acknowledgements to the server need to be sent in due time).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
86 Class Documentation
Properties
See Also
PhotonNetworkingMessage
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.18 PhotonView Class Reference 87
The documentation for this class was generated from the following file:
MonoBehaviour
Photon.MonoBehaviour
PhotonView
• void Awake ()
Called by Unity on start of the application and does a setup the PhotonView.
• void OnApplicationQuit ()
• void OnDestroy ()
• void RPC (string methodName, PhotonTargets target, params object[ ] parameters)
• void RPC (string methodName, PhotonPlayer targetPlayer, params object[ ] parameters)
• override string ToString ()
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
88 Class Documentation
Public Attributes
• int subId
• int ownerId
• int group = 0
• int prefixBackup = -1
• Component observed
• ViewSynchronization synchronization
• OnSerializeTransform onSerializeTransformOption = OnSerializeTransform.PositionAndRotation
• OnSerializeRigidBody onSerializeRigidBodyOption = OnSerializeRigidBody.All
• int instantiationId
Properties
Called by Unity on start of the application and does a setup the PhotonView.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.18 PhotonView Class Reference 89
13.18.2.8 void PhotonView.RPC ( string methodName, PhotonTargets target, params object[ ] parameters )
13.18.2.9 void PhotonView.RPC ( string methodName, PhotonPlayer targetPlayer, params object[ ] parameters )
This is the instantiationData that was passed when calling PhotonNetwork.Instantiate∗ (if that was used to spawn
this prefab)
Is this photonView mine? True in case the owner matches the local PhotonPlayer ALSO true if this is a scene
photonview on the Master client
True if the PhotonView was loaded with the scene (game object) or instantiated with InstantiateSceneObject.
Scene objects are not owned by a particular player but belong to the scene. Thus they don’t get destroyed when
their creator leaves the game and the current Master Client can control them (whoever that is). The ownerIs is 0
(player IDs are 1 and up).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
90 Class Documentation
The documentation for this class was generated from the following file:
This script is automatically added to the PhotonHandler gameobject by PUN. It will auto-ping the ExitGames cloud
regions via Awake. This is done only once per client and the result is saved in PlayerPrefs. Use PhotonNetwork.-
ConnectToBestCloudServer(gameVersion) to connect to cloud region with best ping.
Inheritance diagram for PingCloudRegions:
MonoBehaviour
PingCloudRegions
• IEnumerator PingAllRegions ()
This script is automatically added to the PhotonHandler gameobject by PUN. It will auto-ping the ExitGames cloud
regions via Awake. This is done only once per client and the result is saved in PlayerPrefs. Use PhotonNetwork.-
ConnectToBestCloudServer(gameVersion) to connect to cloud region with best ping.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.20 Room Class Reference 91
Attempts to resolve a hostname into an IP string or returns empty string if that fails.
Parameters
hostString Hostname to resolve.
Returns
The documentation for this class was generated from the following file:
This class resembles a room that PUN joins (or joined). The properties are settable as opposed to those of a
RoomInfo and you can close or hide "your" room.
Inheritance diagram for Room:
RoomInfo
Room
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
92 Class Documentation
The name of a room. Unique identifier (per Loadbalancing group) for a room/match.
• new int maxPlayers [get, set]
Sets a limit of players to this room. This property is shown in lobby, too. If the room is full (players count ==
maxplayers), joining this room will fail.
• new bool open [get, set]
Defines if the room can be joined. This does not affect listing in a lobby but joining the room will fail if not open. If
not open, the room is excluded from random matchmaking. Due to racing conditions, found matches might become
closed before they are joined. Simply re-connect to master and find another. Use property "visible" to not list the
room.
• new bool visible [get, set]
Defines if the room is listed in its lobby. Rooms can be created invisible, or changed to invisible. To change if a room
can be joined, use property: open.
• string[ ] propertiesListedInLobby [get, set]
A list of custom properties that should be forwarded to the lobby and listed there.
• bool autoCleanUp [get]
Gets if this room uses autoCleanUp to remove all (buffered) RPCs and instantiated GameObjects when a player
leaves.
This class resembles a room that PUN joins (or joined). The properties are settable as opposed to those of a
RoomInfo and you can close or hide "your" room.
Updates and synchronizes the named properties of this Room with the values of propertiesToSet.
Any player can set a Room’s properties. Room properties are available until changed, deleted or until the last player
leaves the room. Access them by: Room.CustomProperties (read-only!).
New properties are added, existing values are updated. Other values will not be changed, so only provide values
that changed or are new. To delete a named (custom) property of this room, use null as value. Only string-typed
keys are applied (everything else is ignored).
Local cache is updated immediately, other clients are updated through Photon with a fitting operation. To reduce
network traffic, set only values that actually changed.
Parameters
propertiesToSet Hashtable of props to udpate, set and sync. See description.
Enables you to define the properties available in the lobby if not all properties are needed to pick a room.
It makes sense to limit the amount of properties sent to users in the lobby as this improves speed and stability.
Parameters
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.21 RoomInfo Class Reference 93
Gets if this room uses autoCleanUp to remove all (buffered) RPCs and instantiated GameObjects when a player
leaves.
Sets a limit of players to this room. This property is shown in lobby, too. If the room is full (players count ==
maxplayers), joining this room will fail.
The name of a room. Unique identifier (per Loadbalancing group) for a room/match.
Defines if the room can be joined. This does not affect listing in a lobby but joining the room will fail if not open. If
not open, the room is excluded from random matchmaking. Due to racing conditions, found matches might become
closed before they are joined. Simply re-connect to master and find another. Use property "visible" to not list the
room.
A list of custom properties that should be forwarded to the lobby and listed there.
Defines if the room is listed in its lobby. Rooms can be created invisible, or changed to invisible. To change if a room
can be joined, use property: open.
The documentation for this class was generated from the following file:
A simplified room with just the info required to list and join, used for the room listing in the lobby. The properties are
not settable (open, maxPlayers, etc).
Inheritance diagram for RoomInfo:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
94 Class Documentation
RoomInfo
Room
Protected Attributes
• byte maxPlayersField = 0
Backing field for property.
• bool openField = true
Backing field for property.
• bool visibleField = true
Backing field for property.
• bool autoCleanUpField = false
Backing field for property. False unless the GameProperty is set to true (else it’s not sent).
• string nameField
Backing field for property.
Properties
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.21 RoomInfo Class Reference 95
A simplified room with just the info required to list and join, used for the room listing in the lobby. The properties are
not settable (open, maxPlayers, etc).
This class resembles info about available rooms, as sent by the Master server’s lobby. Consider all values as
readonly. None are synced (only updated by events by server).
Returns
Returns
Backing field for property. False unless the GameProperty is set to true (else it’s not sent).
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
96 Class Documentation
Read-only "cache" of custom properties of a room. Set via Room.SetCustomProperties (not available for RoomInfo
class!).
All keys are string-typed and the values depend on the game/application.
State if the local client is already in the game or still going to join it on gameserver (in lobby always false).
Sets a limit of players to this room. This property is shown in lobby, too. If the room is full (players count ==
maxplayers), joining this room will fail.
As part of RoomInfo this can’t be set. As part of a Room (which the player joined), the setter will update the server
and all clients.
The name of a room. Unique identifier (per Loadbalancing group) for a room/match.
Defines if the room can be joined. This does not affect listing in a lobby but joining the room will fail if not open. If
not open, the room is excluded from random matchmaking. Due to racing conditions, found matches might become
closed before they are joined. Simply re-connect to master and find another. Use property "IsVisible" to not list the
room.
As part of RoomInfo this can’t be set. As part of a Room (which the player joined), the setter will update the server
and all clients.
Only used internally in lobby, to display number of players in room (while you’re not in).
Defines if the room is listed in its lobby. Rooms can be created invisible, or changed to invisible. To change if a room
can be joined, use property: open.
As part of RoomInfo this can’t be set. As part of a Room (which the player joined), the setter will update the server
and all clients.
The documentation for this class was generated from the following file:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.22 ServerSettings Class Reference 97
ScriptableObject
ServerSettings
Public Types
Public Attributes
• static readonly string[ ] CloudServerRegionPrefixes = new string[ ] {"app-eu", "app-us", "app-asia", "app-jp"}
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
98 Class Documentation
Enumerator
NotSet
PhotonCloud
SelfHosted
OfflineMode
13.22.4.2 readonly string [ ] ServerSettings.CloudServerRegionPrefixes = new string[ ] {"app-eu", "app-us", "app-asia", "app-jp"}
[static]
The documentation for this class was generated from the following file:
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 14
File Documentation
Classes
• class CustomTypes
Internally used class, containing de/serialization methods for various Unity-specific classes. Adding those to the
Photon serialization protocol allows you to send them in events, etc.
Enumerations
• enum ConnectionState {
ConnectionState.Disconnected, ConnectionState.Connecting, ConnectionState.Connected, Connection-
State.Disconnecting,
ConnectionState.InitializingApplication }
High level connection state of the client. Better use the more detailed PeerState.
• enum PeerState {
PeerState.Uninitialized, PeerState.PeerCreated, PeerState.Connecting, PeerState.Connected,
PeerState.Queued, PeerState.Authenticated, PeerState.JoinedLobby, PeerState.DisconnectingFrom-
Masterserver,
PeerState.ConnectingToGameserver, PeerState.ConnectedToGameserver, PeerState.Joining, PeerState.-
Joined,
PeerState.Leaving, PeerState.DisconnectingFromGameserver, PeerState.ConnectingToMasterserver, Peer-
100 File Documentation
State.ConnectedComingFromGameserver,
PeerState.QueuedComingFromGameserver, PeerState.Disconnecting, PeerState.Disconnected, PeerState.-
ConnectedToMaster }
Detailed connection / networking peer state. PUN implements a loadbalancing and authentication workflow "behind
the scenes", so some states will automatically advance to some follow up state. Those states are commented with
"(will-change)".
• enum PhotonNetworkingMessage {
PhotonNetworkingMessage.OnConnectedToPhoton, PhotonNetworkingMessage.OnLeftRoom, Photon-
NetworkingMessage.OnMasterClientSwitched, PhotonNetworkingMessage.OnPhotonCreateRoomFailed,
PhotonNetworkingMessage.OnPhotonJoinRoomFailed, PhotonNetworkingMessage.OnCreatedRoom,
PhotonNetworkingMessage.OnJoinedLobby, PhotonNetworkingMessage.OnLeftLobby,
PhotonNetworkingMessage.OnDisconnectedFromPhoton, PhotonNetworkingMessage.OnConnectionFail,
PhotonNetworkingMessage.OnFailedToConnectToPhoton, PhotonNetworkingMessage.OnReceivedRoom-
ListUpdate,
PhotonNetworkingMessage.OnJoinedRoom, PhotonNetworkingMessage.OnPhotonPlayerConnected,
PhotonNetworkingMessage.OnPhotonPlayerDisconnected, PhotonNetworkingMessage.OnPhotonRandom-
JoinFailed,
PhotonNetworkingMessage.OnConnectedToMaster, PhotonNetworkingMessage.OnPhotonSerializeView,
PhotonNetworkingMessage.OnPhotonInstantiate, PhotonNetworkingMessage.OnPhotonMaxCccuReached,
PhotonNetworkingMessage.OnPhotonCustomRoomPropertiesChanged, PhotonNetworkingMessage.On-
PhotonPlayerPropertiesChanged, PhotonNetworkingMessage.OnUpdatedFriendList, PhotonNetworking-
Message.OnCustomAuthenticationFailed }
This enum makes up the set of MonoMessages sent by Photon Unity Networking. Implement any of these constant
names as method and it will be called in the respective situation.
• enum DisconnectCause {
DisconnectCause.ExceptionOnConnect = StatusCode.ExceptionOnConnect, DisconnectCause.Security-
ExceptionOnConnect = StatusCode.SecurityExceptionOnConnect, DisconnectCause.TimeoutDisconnect
= StatusCode.TimeoutDisconnect, DisconnectCause.DisconnectByClientTimeout = StatusCode.Timeout-
Disconnect,
DisconnectCause.InternalReceiveException = StatusCode.ExceptionOnReceive, DisconnectCause.-
DisconnectByServer = StatusCode.DisconnectByServer, DisconnectCause.DisconnectByServerTimeout
= StatusCode.DisconnectByServer, DisconnectCause.DisconnectByServerLogic = StatusCode.Disconnect-
ByServerLogic,
DisconnectCause.DisconnectByServerUserLimit = StatusCode.DisconnectByServerUserLimit, Disconnect-
Cause.Exception = StatusCode.Exception, DisconnectCause.InvalidRegion = ErrorCode.InvalidRegion,
DisconnectCause.MaxCcuReached = ErrorCode.MaxCcuReached }
Summarizes the cause for a disconnect. Used in: OnConnectionFail and OnFailedToConnectToPhoton.
High level connection state of the client. Better use the more detailed PeerState.
Enumerator
Disconnected
Connecting
Connected
Disconnecting
InitializingApplication
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
14.9 Photon Unity Networking/Plugins/PhotonNetwork/FriendInfo.cs File Reference 101
Classes
• class Extensions
This static class defines some useful extension methods for several existing classes (e.g. Vector3, float and others).
Typedefs
Classes
• class FriendInfo
Used to store info about a friend’s online state and in which room he/she is.
Classes
• class LoadbalancingPeer
Internally used by PUN, a LoadbalancingPeer provides the operations and enum definitions needed to use the Photon
Loadbalancing server (or the Photon Cloud).
• class ErrorCode
Class for constants. These (int) values represent error codes, as defined and sent by the Photon LoadBalancing logic.
Pun uses these constants internally.
• class ActorProperties
Class for constants. These (byte) values define "well known" properties for an Actor / Player. Pun uses these
constants internally.
• class GameProperties
Class for constants. These (byte) values are for "well known" room/game properties used in Photon Loadbalancing.
Pun uses these constants internally.
• class EventCode
Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses these constants
internally.
• class ParameterCode
Class for constants. Codes for parameters of Operations and Events. Pun uses these constants internally.
• class OperationCode
Class for constants. Contains operation codes. Pun uses these constants internally.
• class AuthenticationValues
Container for "Custom Authentication" values in Photon (default: user and token). Set AuthParameters before con-
necting - all else is handled.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
102 File Documentation
Typedefs
Enumerations
Options for optional "Custom Authentication" services used with Photon. Used by OpAuthenticate after connecting
to Photon.
Enumerator
Custom Use a custom authentification service. Currently the only implemented option.
Steam Authenticates users by their Steam Account. Set auth values accordingly!
Facebook Authenticates users by their Facebook Account. Set auth values accordingly!
None Disables custom authentification. Same as not providing any AuthenticationValues for connect (more
precisely for: OpAuthenticate).
Enumerator
FillRoom Fills up rooms (oldest first) to get players together as fast as possible. Default.Makes most sense
with MaxPlayers > 0 and games that can only start with more players.
SerialMatching Distributes players across available rooms sequentially but takes filter into account. Without
filter, rooms get players evenly distributed.
RandomMatching Joins a (fully) random room. Expected properties must match but aside from this, any
available room might be selected.
Classes
• class NetworkingPeer
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
14.12 Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs File Reference 103
Implements Photon LoadBalancing used in PUN. This class is used internally by PhotonNetwork and not intended as
public API.
Typedefs
Classes
• class PunEvent
Class for constants. Defines photon-event-codes for PUN usage.
• class Photon.MonoBehaviour
This class adds the property photonView, while logging a warning when your game still uses the networkView.
• class PhotonMessageInfo
Container class for info about a particular message, RPC or update.
• class PBitStream
• class PhotonStream
This "container" class is used to carry your data as written by OnPhotonSerializeView.
Namespaces
• package Photon
Constant Groups
• package Photon
Enumerations
• enum PhotonTargets {
PhotonTargets.All, PhotonTargets.Others, PhotonTargets.MasterClient, PhotonTargets.AllBuffered,
PhotonTargets.OthersBuffered }
Enum of "target" options for RPCs. These define which remote clients get your RPC call.
• enum PhotonLogLevel { PhotonLogLevel.ErrorsOnly, PhotonLogLevel.Informational, PhotonLogLevel.Full }
Used to define the level of logging output created by the PUN classes. Either log errors, info (some more) or full.
Classes
• class PhotonHandler
Internal Monobehaviour that allows Photon to run an Update loop.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
104 File Documentation
Typedefs
Classes
• class PhotonLagSimulationGui
This MonoBehaviour is a basic GUI for the Photon client’s network-simulation feature. It can modify lag (fixed delay),
jitter (random lag) and packet loss.
Classes
• class PhotonNetwork
The main class to use the PhotonNetwork plugin. This class is static.
Typedefs
Classes
• class PhotonPlayer
Summarizes a "player" within a room, identified (in that room) by actorID.
Typedefs
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
14.17 Photon Unity Networking/Plugins/PhotonNetwork/PhotonStatsGui.cs File Reference 105
Classes
• class PhotonStatsGui
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.
Classes
• class PhotonView
PUN’s NetworkView replacement class for networking. Use it like a NetworkView.
Enumerations
Enumerator
OnlyVelocity
OnlyAngularVelocity
All
Enumerator
OnlyPosition
OnlyRotation
OnlyScale
PositionAndRotation
All
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
106 File Documentation
Enumerator
Off
ReliableDeltaCompressed
Unreliable
UnreliableOnChange
Classes
• class PingCloudRegions
This script is automatically added to the PhotonHandler gameobject by PUN. It will auto-ping the ExitGames cloud
regions via Awake. This is done only once per client and the result is saved in PlayerPrefs. Use PhotonNetwork.-
ConnectToBestCloudServer(gameVersion) to connect to cloud region with best ping.
Classes
• class Room
This class resembles a room that PUN joins (or joined). The properties are settable as opposed to those of a Room-
Info and you can close or hide "your" room.
Classes
• class RoomInfo
A simplified room with just the info required to list and join, used for the room listing in the lobby. The properties are
not settable (open, maxPlayers, etc).
Classes
• class ServerSettings
Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsingSettings.
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
14.24 Photon Unity Networking/Plugins/PhotonNetwork/ServerSettings.cs File Reference 107
Enumerations
Enumerator
EU
US
Asia
Japan
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Index
_Doc/general.md, 99 Authenticated
_Doc/main.md, 99 Public API, 32
_Doc/optionalGui.md, 99 AuthenticationValues, 37
_Doc/photonStatsGui.md, 99 AuthParameters, 39
_Doc/publicApi.md, 99 AuthPostData, 39
AuthType, 39
ActorList Secret, 39
ParameterCode, 53 SetAuthParameters, 38
ActorNr SetAuthPostData, 38, 39
ParameterCode, 53 ToString, 39
ActorProperties, 37 autoCleanUp
PlayerName, 37 Room, 93
Add autoCleanUpField
ParameterCode, 53 RoomInfo, 95
PBitStream, 56 autoCleanUpPlayerObjects
Address PhotonNetwork, 77
ParameterCode, 53 autoJoinLobby
All PhotonNetwork, 78
PhotonView.cs, 105 automaticallySyncScene
Public API, 34 PhotonNetwork, 78
AllBuffered Awake
Public API, 34 PhotonView, 88
allProperties AzureNodeInfo
PhotonPlayer, 83 EventCode, 43
AllocateViewID
PhotonNetwork, 64 BitCount
AlmostEquals PBitStream, 57
Extensions, 45 Broadcast
AlreadyMatched ParameterCode, 53
ErrorCode, 40 buttonsOn
AppID PhotonStatsGui, 85
ServerSettings, 98 ByteCount
AppStats PBitStream, 57
EventCode, 43 BytesForBits
AppVersion PBitStream, 56
ParameterCode, 53
ApplicationId Cache
ParameterCode, 53 ParameterCode, 53
Asia ChangeGroups
ServerSettings.cs, 107 OperationCode, 50
AuthParameters CleanupCacheOnLeave
AuthenticationValues, 39 GameProperties, 48
AuthPostData ParameterCode, 53
AuthenticationValues, 39 ClientAuthenticationData
AuthType ParameterCode, 53
AuthenticationValues, 39 ClientAuthenticationParams
AuthValues ParameterCode, 53
PhotonNetwork, 77 ClientAuthenticationType
Authenticate ParameterCode, 54
OperationCode, 50 CloseConnection
INDEX 109
PhotonNetwork, 64 PhotonNetwork, 66
closestRegion Custom
PingCloudRegions, 91 LoadbalancingPeer.cs, 102
CloudServerRegion CustomAuthenticationFailed
ServerSettings.cs, 107 ErrorCode, 40
CloudServerRegionPrefixes CustomAuthenticationType
ServerSettings, 98 LoadbalancingPeer.cs, 102
Code CustomEventContent
ParameterCode, 54 ParameterCode, 54
Connect customProperties
PhotonNetwork, 64 PhotonPlayer, 83
ConnectToBestCloudServer RoomInfo, 96
PhotonNetwork, 65
ConnectToBestRegion Data
PingCloudRegions, 90 ParameterCode, 54
ConnectUsingSettings DefaultAppID
PhotonNetwork, 65 ServerSettings, 98
Connected DefaultCloudServerUrl
Enums.cs, 100 ServerSettings, 98
DefaultMasterPort
Public API, 32
ServerSettings, 98
connected
DefaultServerAddress
PhotonNetwork, 78
ServerSettings, 98
ConnectedComingFromGameserver
Destroy
Public API, 32
PhotonNetwork, 67
ConnectedToGameserver
DestroyAll
Public API, 32
PhotonNetwork, 67
ConnectedToMaster
DestroyPlayerObjects
Public API, 32
PhotonNetwork, 68
Connecting
DisableAutoOpenWizard
Enums.cs, 100
ServerSettings, 98
Public API, 32
Disconnect
ConnectingToGameserver
PhotonNetwork, 68
Public API, 32
DisconnectByClientTimeout
ConnectingToMasterserver
Public API, 31
Public API, 32
DisconnectByServer
ConnectionState
Public API, 31
Enums.cs, 100
DisconnectByServerLogic
connectionState
Public API, 31
PhotonNetwork, 78
DisconnectByServerTimeout
connectionStateDetailed Public API, 31
PhotonNetwork, 78 DisconnectByServerUserLimit
Contains Public API, 32
Extensions, 45 DisconnectCause
Count Public API, 31
PhotonStream, 87 Disconnected
countOfPlayers Enums.cs, 100
PhotonNetwork, 78 Public API, 32
countOfPlayersInRooms Disconnecting
PhotonNetwork, 78 Enums.cs, 100
countOfPlayersOnMaster Public API, 32
PhotonNetwork, 78 DisconnectingFromGameserver
countOfRooms Public API, 32
PhotonNetwork, 78 DisconnectingFromMasterserver
CreateGame Public API, 32
OperationCode, 50
CreateIfNotExists EU
ParameterCode, 54 ServerSettings.cs, 107
CreateRoom Enums.cs
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
110 INDEX
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
INDEX 111
PropsListedInLobby, 48 InternalCleanPhotonMonoFromSceneIfStuck
Removed, 48 PhotonNetwork, 71
Get InternalServerError
PBitStream, 57 ErrorCode, 41
PhotonView, 88 InvalidRegion
GetHashCode Public API, 32
PhotonPlayer, 83 InvalidAuthentication
RoomInfo, 95 ErrorCode, 41
GetNext InvalidOperationCode
PBitStream, 57 ErrorCode, 41
GetPhotonView InvalidRegion
Extensions, 45 ErrorCode, 41
GetPhotonViewsInChildren IsInRoom
Extensions, 45 FriendInfo, 47
GetPing isLocal
PhotonNetwork, 69 PhotonPlayer, 83
GetProperties isLocalClientInside
OperationCode, 50 RoomInfo, 96
GetRoomList isMasterClient
PhotonNetwork, 69 PhotonNetwork, 79
Group PhotonPlayer, 83
ParameterCode, 55 isMessageQueueRunning
group PhotonNetwork, 79
PhotonView, 89 isMine
PhotonView, 89
Hashtable isNonMasterClientInRoom
Extensions.cs, 101 PhotonNetwork, 79
LoadbalancingPeer.cs, 102 IsOnline
NetworkingPeer.cs, 103 FriendInfo, 47
PhotonHandler.cs, 104 IsOpen
PhotonNetwork.cs, 104 GameProperties, 48
PhotonPlayer.cs, 104 isReading
healthStatsVisible PhotonStream, 87
PhotonStatsGui, 85 isSceneView
HostType PhotonView, 89
ServerSettings, 98 IsVisible
HostingOption GameProperties, 48
ServerSettings, 98 isWriting
PhotonStream, 87
ID
PhotonPlayer, 83 Japan
Informational ServerSettings.cs, 107
Public API, 33 Join
InitializeSecurity EventCode, 43
PhotonNetwork, 70 JoinGame
InitializingApplication OperationCode, 50
Enums.cs, 100 JoinLobby
insideLobby OperationCode, 50
PhotonNetwork, 79 JoinRandomGame
Instantiate OperationCode, 50
PhotonNetwork, 70 JoinRandomRoom
InstantiateSceneObject PhotonNetwork, 71
PhotonNetwork, 70 JoinRoom
instantiationData PhotonNetwork, 72
PhotonView, 89 Joined
instantiationId Public API, 32
PhotonView, 89 JoinedLobby
InternalReceiveException Public API, 32
Public API, 31 Joining
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
112 INDEX
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
INDEX 113
OnPhotonCreateRoomFailed FindFriends, 50
Public API, 33 GetProperties, 50
OnPhotonCustomRoomPropertiesChanged JoinGame, 50
Public API, 34 JoinLobby, 50
OnPhotonInstantiate JoinRandomGame, 50
Public API, 34 Leave, 50
OnPhotonJoinRoomFailed LeaveLobby, 51
Public API, 33 RaiseEvent, 51
OnPhotonMaxCccuReached SetProperties, 51
Public API, 34 OperationNotAllowedInCurrentState
OnPhotonPlayerConnected ErrorCode, 42
Public API, 34 Optional Gui Elements, 29
OnPhotonPlayerDisconnected otherPlayers
Public API, 34 PhotonNetwork, 80
OnPhotonPlayerPropertiesChanged Others
Public API, 34 Public API, 34
OnPhotonRandomJoinFailed OthersBuffered
Public API, 34 Public API, 34
OnPhotonSerializeView OverrideBestCloudServer
Public API, 34 PhotonNetwork, 73
OnReceivedRoomListUpdate OverrideRegion
Public API, 33 PingCloudRegions, 90
OnUpdatedFriendList owner
Public API, 34 PhotonView, 89
OnApplicationQuit OwnerActorNr
PhotonView, 89 PhotonView, 89
OnDestroy ownerId
PhotonView, 89 PhotonView, 89
OnGUI PBitStream, 56
PhotonLagSimulationGui, 58 Add, 56
PhotonStatsGui, 85 BitCount, 57
OnSerializeRigidBody ByteCount, 57
PhotonView.cs, 105 BytesForBits, 56
onSerializeRigidBodyOption Get, 57
PhotonView, 89 GetNext, 57
OnSerializeTransform PBitStream, 56
PhotonView.cs, 105 PBitStream, 56
onSerializeTransformOption Position, 57
PhotonView, 89 Set, 57
OnlyAngularVelocity ToBytes, 57
PhotonView.cs, 105 ParameterCode, 51
OnlyPosition ActorList, 53
PhotonView.cs, 105 ActorNr, 53
OnlyRotation Add, 53
PhotonView.cs, 105 Address, 53
OnlyScale AppVersion, 53
PhotonView.cs, 105 ApplicationId, 53
OnlyVelocity Broadcast, 53
PhotonView.cs, 105 Cache, 53
open CleanupCacheOnLeave, 53
Room, 93 ClientAuthenticationData, 53
RoomInfo, 96 ClientAuthenticationParams, 53
openField ClientAuthenticationType, 54
RoomInfo, 95 Code, 54
OperationCode, 49 CreateIfNotExists, 54
Authenticate, 50 CustomEventContent, 54
ChangeGroups, 50 Data, 54
CreateGame, 50 FindFriendsRequestList, 54
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
114 INDEX
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
INDEX 115
countOfPlayersOnMaster, 78 SetReceivingEnabled, 75
countOfRooms, 78 SetSendingEnabled, 75
CreateRoom, 66 time, 80
Destroy, 67 UnAllocateViewID, 76
DestroyAll, 67 unreliableCommandsLimit, 81
DestroyPlayerObjects, 68 UsePrefabCache, 77
Disconnect, 68 versionPUN, 77
FetchServerTimestamp, 69 PhotonNetwork.cs
FindFriends, 69 Hashtable, 104
Friends, 78 PhotonNetworkingMessage
FriendsListAge, 79 Public API, 33
GetPing, 69 PhotonPlayer, 81
GetRoomList, 69 allProperties, 83
InitializeSecurity, 70 customProperties, 83
insideLobby, 79 Equals, 82
Instantiate, 70 Find, 82
InstantiateSceneObject, 70 GetHashCode, 83
InternalCleanPhotonMonoFromSceneIfStuck, 71 ID, 83
isMasterClient, 79 isLocal, 83
isMessageQueueRunning, 79 isMasterClient, 83
isNonMasterClientInRoom, 79 name, 84
JoinRandomRoom, 71 PhotonPlayer, 82
JoinRoom, 72 PhotonPlayer, 82
LeaveRoom, 72 SetCustomProperties, 83
LoadLevel, 72, 73 ToString, 83
logLevel, 76 PhotonPlayer.cs
MAX_VIEW_IDS, 76 Hashtable, 104
masterClient, 79 PhotonServerSettings
maxConnections, 79 PhotonNetwork, 76
NetworkStatisticsEnabled, 79 PhotonStatsGui, 84
NetworkStatisticsReset, 73 buttonsOn, 85
NetworkStatisticsToString, 73 healthStatsVisible, 85
offlineMode, 79 OnGUI, 85
otherPlayers, 80 Start, 85
OverrideBestCloudServer, 73 statsOn, 85
PhotonServerSettings, 76 statsRect, 85
player, 80 statsWindowOn, 85
playerList, 80 trafficStatsOn, 85
playerName, 80 TrafficStatsWindow, 85
precisionForFloatSynchronization, 76 Update, 85
precisionForQuaternionSynchronization, 76 WindowId, 85
precisionForVectorSynchronization, 76 PhotonStream, 86
PrefabCache, 76 Count, 87
RefreshCloudServerRating, 73 isReading, 87
RemoveRPCs, 73, 74 isWriting, 87
RemoveRPCsInGroup, 74 PhotonStream, 86
ResentReliableCommands, 80 PhotonStream, 86
room, 80 ReceiveNext, 86
SendMonoMessageTargets, 76 SendNext, 86
SendOutgoingCommands, 74 Serialize, 86, 87
sendRate, 80 ToArray, 87
sendRateOnSerialize, 80 PhotonTargets
ServerAddress, 80 Public API, 34
serverSettingsAssetFile, 77 PhotonView, 87
serverSettingsAssetPath, 77 Awake, 88
SetLevelPrefix, 74 ExecuteOnSerialize, 88
SetMasterClient, 75 Find, 88
SetPlayerCustomProperties, 75 Get, 88
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
116 INDEX
group, 89 PhotonNetwork, 76
instantiationData, 89 precisionForQuaternionSynchronization
instantiationId, 89 PhotonNetwork, 76
isMine, 89 precisionForVectorSynchronization
isSceneView, 89 PhotonNetwork, 76
observed, 89 PrefabCache
OnApplicationQuit, 89 PhotonNetwork, 76
OnDestroy, 89 prefix
onSerializeRigidBodyOption, 89 PhotonView, 90
onSerializeTransformOption, 89 prefixBackup
owner, 89 PhotonView, 89
OwnerActorNr, 89 Properties
ownerId, 89 ParameterCode, 55
prefix, 90 PropertiesChanged
prefixBackup, 89 EventCode, 43
RPC, 89 propertiesListedInLobby
subId, 89 Room, 93
synchronization, 89 PropsListedInLobby
ToString, 89 GameProperties, 48
viewID, 90 Public API
photonView All, 34
Photon::MonoBehaviour, 49 AllBuffered, 34
PhotonMessageInfo, 59 Authenticated, 32
PhotonView.cs Connected, 32
OnSerializeRigidBody, 105 ConnectedComingFromGameserver, 32
OnSerializeTransform, 105 ConnectedToGameserver, 32
ViewSynchronization, 105 ConnectedToMaster, 32
PingAllRegions Connecting, 32
PingCloudRegions, 91 ConnectingToGameserver, 32
PingCloudRegions, 90 ConnectingToMasterserver, 32
closestRegion, 91 DisconnectByClientTimeout, 31
ConnectToBestRegion, 90 DisconnectByServer, 31
OverrideRegion, 90 DisconnectByServerLogic, 31
PingAllRegions, 91 DisconnectByServerTimeout, 31
RefreshCloudServerRating, 91 DisconnectByServerUserLimit, 32
ResolveHost, 91 Disconnected, 32
SP, 91 Disconnecting, 32
player DisconnectingFromGameserver, 32
PhotonNetwork, 80 DisconnectingFromMasterserver, 32
PlayerCount ErrorsOnly, 33
GameProperties, 48 Exception, 32
playerCount ExceptionOnConnect, 31
Room, 93 Full, 33
RoomInfo, 96 Informational, 33
playerList InternalReceiveException, 31
PhotonNetwork, 80 InvalidRegion, 32
PlayerName Joined, 32
ActorProperties, 37 JoinedLobby, 32
playerName Joining, 32
PhotonNetwork, 80 Leaving, 32
PlayerProperties MasterClient, 34
ParameterCode, 55 MaxCcuReached, 32
Position OnConnectedToMaster, 34
ParameterCode, 55 OnConnectedToPhoton, 33
PBitStream, 57 OnConnectionFail, 33
PositionAndRotation OnCreatedRoom, 33
PhotonView.cs, 105 OnCustomAuthenticationFailed, 34
precisionForFloatSynchronization OnDisconnectedFromPhoton, 33
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
INDEX 117
OnFailedToConnectToPhoton, 33 RemoveRPCsInGroup
OnJoinedLobby, 33 PhotonNetwork, 74
OnJoinedRoom, 33 Removed
OnLeftLobby, 33 GameProperties, 48
OnLeftRoom, 33 removedFromList
OnMasterClientSwitched, 33 RoomInfo, 96
OnPhotonCreateRoomFailed, 33 ResentReliableCommands
OnPhotonCustomRoomPropertiesChanged, 34 PhotonNetwork, 80
OnPhotonInstantiate, 34 ResolveHost
OnPhotonJoinRoomFailed, 33 PingCloudRegions, 91
OnPhotonMaxCccuReached, 34 Room, 91
OnPhotonPlayerConnected, 34 autoCleanUp, 93
OnPhotonPlayerDisconnected, 34 FriendInfo, 47
OnPhotonPlayerPropertiesChanged, 34 maxPlayers, 93
OnPhotonRandomJoinFailed, 34 name, 93
OnPhotonSerializeView, 34 open, 93
OnReceivedRoomListUpdate, 33 playerCount, 93
OnUpdatedFriendList, 34 propertiesListedInLobby, 93
Others, 34 SetCustomProperties, 92
OthersBuffered, 34 SetPropertiesListedInLobby, 92
PeerCreated, 32 visible, 93
Queued, 32 room
QueuedComingFromGameserver, 32 PhotonNetwork, 80
SecurityExceptionOnConnect, 31 RoomInfo, 93
TimeoutDisconnect, 31 autoCleanUpField, 95
Uninitialized, 32 customProperties, 96
Public API, 30 Equals, 95
DisconnectCause, 31 GetHashCode, 95
PeerState, 32 isLocalClientInside, 96
PhotonLogLevel, 32 maxPlayers, 96
PhotonNetworkingMessage, 33 maxPlayersField, 95
PhotonTargets, 34 name, 96
nameField, 95
QueueState open, 96
EventCode, 43 openField, 95
Queued playerCount, 96
Public API, 32 removedFromList, 96
QueuedComingFromGameserver ToString, 95
Public API, 32 visible, 96
visibleField, 95
RPC RoomName
PhotonView, 89 ParameterCode, 55
RaiseEvent RpcList
OperationCode, 51 ServerSettings, 98
RandomMatching
LoadbalancingPeer.cs, 102 SP
ReceiveNext PingCloudRegions, 91
PhotonStream, 86 Secret
ReceiverGroup AuthenticationValues, 39
ParameterCode, 55 ParameterCode, 55
RefreshCloudServerRating SecurityExceptionOnConnect
PhotonNetwork, 73 Public API, 31
PingCloudRegions, 91 SelfHosted
ReliableDeltaCompressed ServerSettings, 98
PhotonView.cs, 106 SendMonoMessageTargets
Remove PhotonNetwork, 76
ParameterCode, 55 SendNext
RemoveRPCs PhotonStream, 86
PhotonNetwork, 73, 74 SendOutgoingCommands
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
118 INDEX
PhotonNetwork, 74 SetCustomProperties
sendRate PhotonPlayer, 83
PhotonNetwork, 80 Room, 92
sendRateOnSerialize SetLevelPrefix
PhotonNetwork, 80 PhotonNetwork, 74
sender SetMasterClient
PhotonMessageInfo, 59 PhotonNetwork, 75
SerialMatching SetPlayerCustomProperties
LoadbalancingPeer.cs, 102 PhotonNetwork, 75
Serialize SetProperties
PhotonStream, 86, 87 EventCode, 44
ServerSettings OperationCode, 51
NotSet, 98 SetPropertiesListedInLobby
OfflineMode, 98 Room, 92
PhotonCloud, 98 SetReceivingEnabled
SelfHosted, 98 PhotonNetwork, 75
ServerSettings.cs SetSendingEnabled
Asia, 107 PhotonNetwork, 75
EU, 107 Start
Japan, 107 PhotonLagSimulationGui, 58
US, 107 PhotonStatsGui, 85
ServerAddress statsOn
PhotonNetwork, 80 PhotonStatsGui, 85
ServerSettings, 98 statsRect
ServerFull PhotonStatsGui, 85
ErrorCode, 42 statsWindowOn
ServerPort PhotonStatsGui, 85
ServerSettings, 98 Steam
ServerSettings, 97 LoadbalancingPeer.cs, 102
AppID, 98 StripKeysWithNullValues
Extensions, 46
CloudServerRegionPrefixes, 98
StripToStringKeys
DefaultAppID, 98
Extensions, 46
DefaultCloudServerUrl, 98
subId
DefaultMasterPort, 98
PhotonView, 89
DefaultServerAddress, 98
SupportClass
DisableAutoOpenWizard, 98
Extensions.cs, 101
FindRegionForServerAddress, 98
synchronization
FindServerAddressForRegion, 98
PhotonView, 89
HostType, 98
HostingOption, 98 TargetActorNr
RpcList, 98 ParameterCode, 56
ServerAddress, 98 time
ServerPort, 98 PhotonNetwork, 80
ToString, 98 TimeoutDisconnect
UseCloud, 98 Public API, 31
UseMyServer, 98 timestamp
ServerSettings.cs PhotonMessageInfo, 59
CloudServerRegion, 107 ToArray
serverSettingsAssetFile PhotonStream, 87
PhotonNetwork, 77 ToBytes
serverSettingsAssetPath PBitStream, 57
PhotonNetwork, 77 ToString
Set AuthenticationValues, 39
PBitStream, 57 FriendInfo, 47
SetAuthParameters PhotonMessageInfo, 59
AuthenticationValues, 38 PhotonPlayer, 83
SetAuthPostData PhotonView, 89
AuthenticationValues, 38, 39 RoomInfo, 95
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
INDEX 119
ServerSettings, 98
ToStringFull
Extensions, 46
trafficStatsOn
PhotonStatsGui, 85
TrafficStatsWindow
PhotonStatsGui, 85
US
ServerSettings.cs, 107
UnAllocateViewID
PhotonNetwork, 76
Uninitialized
Public API, 32
Unreliable
PhotonView.cs, 106
UnreliableOnChange
PhotonView.cs, 106
unreliableCommandsLimit
PhotonNetwork, 81
Update
PhotonStatsGui, 85
UseCloud
ServerSettings, 98
UseMyServer
ServerSettings, 98
UsePrefabCache
PhotonNetwork, 77
UserBlocked
ErrorCode, 42
UserId
ParameterCode, 56
versionPUN
PhotonNetwork, 77
viewID
PhotonView, 90
ViewSynchronization
PhotonView.cs, 105
Visible
PhotonLagSimulationGui, 58
visible
Room, 93
RoomInfo, 96
visibleField
RoomInfo, 95
WindowId
PhotonLagSimulationGui, 58
PhotonStatsGui, 85
WindowRect
PhotonLagSimulationGui, 58
Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen