0% found this document useful (0 votes)
30 views135 pages

PhotonNetwork Documentation

This document provides documentation for Photon Unity Networking version 1.24, including: - Overviews of the general documentation, GUI for network simulation, and GUI for network statistics. - Descriptions of the public API, modules, namespaces, class hierarchy, classes, files, and other elements. - Detailed documentation for classes like ActorProperties, AuthenticationValues, ErrorCode, and EventCode, which are used in Photon networking. The document contains all relevant references and information for understanding and using the Photon Unity Networking library.

Uploaded by

dev fazza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views135 pages

PhotonNetwork Documentation

This document provides documentation for Photon Unity Networking version 1.24, including: - Overviews of the general documentation, GUI for network simulation, and GUI for network statistics. - Descriptions of the public API, modules, namespaces, class hierarchy, classes, files, and other elements. - Detailed documentation for classes like ActorProperties, AuthenticationValues, ErrorCode, and EventCode, which are used in Photon networking. The document contains all relevant references and information for understanding and using the Photon Unity Networking library.

Uploaded by

dev fazza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 135

Photon Unity Networking

v1.24

Generated by Doxygen 1.8.4

Thu Oct 17 2013 18:24:41


Contents

1 Main Page 1

2 General Documentation 3

3 Gui for Network Simulation 13

4 Gui for Network Statistics 15

5 What is the public PUN api 17

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

13.7.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48


13.7.2.1 CleanupCacheOnLeave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.2 IsOpen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.3 IsVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.4 MaxPlayers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.5 PlayerCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.6 PropsListedInLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.7.2.7 Removed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.8 Photon.MonoBehaviour Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
13.8.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
13.8.2 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
13.8.2.1 networkView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
13.8.2.2 photonView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
13.9 OperationCode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
13.9.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.1 Authenticate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.2 ChangeGroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.3 CreateGame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.4 FindFriends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.5 GetProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.6 JoinGame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.7 JoinLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.8 JoinRandomGame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
13.9.2.9 Leave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.9.2.10 LeaveLobby . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.9.2.11 RaiseEvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.9.2.12 SetProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.10ParameterCode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.10.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.1 ActorList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.2 ActorNr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.3 Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.4 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.5 ApplicationId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.6 AppVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.7 Broadcast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.8 Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
13.10.2.9 CleanupCacheOnLeave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

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

13.15.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82


13.15.2 Constructor & Destructor Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.2.1 PhotonPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.2.2 PhotonPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.3 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.3.1 Equals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.3.2 Find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
13.15.3.3 GetHashCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.3.4 SetCustomProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.3.5 ToString . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.4 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.4.1 isLocal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.5 Property Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.5.1 allProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.5.2 customProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.5.3 ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
13.15.5.4 isMasterClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
13.15.5.5 name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
13.16PhotonStatsGui Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
13.16.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.2 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.2.1 OnGUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.2.2 Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.2.3 TrafficStatsWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.2.4 Update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3 Member Data Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.1 buttonsOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.2 healthStatsVisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.3 statsOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.4 statsRect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.5 statsWindowOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.6 trafficStatsOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.16.3.7 WindowId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
13.17PhotonStream Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.1 Detailed Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.2 Constructor & Destructor Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.2.1 PhotonStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3 Member Function Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.1 ReceiveNext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
13.17.3.2 SendNext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

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

14.5 _Doc/publicApi.md File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99


14.6 Photon Unity Networking/Plugins/PhotonNetwork/CustomTypes.cs File Reference . . . . . . . . . 99
14.7 Photon Unity Networking/Plugins/PhotonNetwork/Enums.cs File Reference . . . . . . . . . . . . . 99
14.7.1 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
14.7.1.1 ConnectionState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
14.8 Photon Unity Networking/Plugins/PhotonNetwork/Extensions.cs File Reference . . . . . . . . . . . 100
14.8.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
14.8.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
14.8.1.2 SupportClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
14.9 Photon Unity Networking/Plugins/PhotonNetwork/FriendInfo.cs File Reference . . . . . . . . . . . 101
14.10Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs File Reference . . . . . . 101
14.10.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
14.10.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
14.10.2 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
14.10.2.1 CustomAuthenticationType . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
14.10.2.2 MatchmakingMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
14.11Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs File Reference . . . . . . . . 102
14.11.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
14.11.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
14.12Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs File Reference . . . . . . . . 103
14.13Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs File Reference . . . . . . . . . 103
14.13.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.13.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.14Photon Unity Networking/Plugins/PhotonNetwork/PhotonLagSimulationGui.cs File Reference . . . 104
14.15Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs File Reference . . . . . . . . 104
14.15.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.15.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.16Photon Unity Networking/Plugins/PhotonNetwork/PhotonPlayer.cs File Reference . . . . . . . . . 104
14.16.1 Typedef Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.16.1.1 Hashtable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.17Photon Unity Networking/Plugins/PhotonNetwork/PhotonStatsGui.cs File Reference . . . . . . . . 105
14.18Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs File Reference . . . . . . . . . . 105
14.18.1 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
14.18.1.1 OnSerializeRigidBody . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
14.18.1.2 OnSerializeTransform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
14.18.1.3 ViewSynchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
14.19Photon Unity Networking/Plugins/PhotonNetwork/PingCloudRegions.cs File Reference . . . . . . . 106
14.20Photon Unity Networking/Plugins/PhotonNetwork/Room.cs File Reference . . . . . . . . . . . . . 106
14.21Photon Unity Networking/Plugins/PhotonNetwork/RoomInfo.cs File Reference . . . . . . . . . . . 106
14.22Photon Unity Networking/Plugins/PhotonNetwork/RPC.cs File Reference . . . . . . . . . . . . . . 106

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
xvi CONTENTS

14.23Photon Unity Networking/Plugins/PhotonNetwork/RpcIndexComponent.cs File Reference . . . . . 106


14.24Photon Unity Networking/Plugins/PhotonNetwork/ServerSettings.cs File Reference . . . . . . . . . 106
14.24.1 Enumeration Type Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
14.24.1.1 CloudServerRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

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

• Server available as hosted service (free of charge for development)

• Partially automatic conversion from Unity Networking to PUN

• Offline mode: re-use your multiplayer code in singleplayer game modes

• Outstanding performance of the Photon Server

• Load balanced workflow scales across servers (with no extra effort)

• No direct P2P and no NAT punch-through needed

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.

Exit Games Cloud

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.

Subscriptions bought in Asset Store

Follow these steps, if you bought a package with Photon Cloud Subscription in the Asset Store:

• Register a Photon Cloud Account: cloud.exitgames.com

• Get your AppID from the Dashboard

• Send a Mail to: [email protected]

• With:

– Your Name and Company (if applicable)


– Invoice/Purchase ID from the Asset Store
– Photon Cloud AppID

Photon Server SDK

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

The Photon v3.2 SDK can be downloaded on: http://www.exitgames.com/Download/Photon Starting


the Server: http://doc.exitgames.com/photon-server/PhotonIn5Min

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.

Master Server And Lobby

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).

Creating and Joining Games

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

//Create this room.


PhotonNetwork.CreateRoom(roomName);
// Fails if it already exists and calls: OnPhotonCreateGameFailed

//Tries to join any random game:


PhotonNetwork.JoinRandomRoom();
//Fails if there are no matching games: OnPhotonRandomJoinFailed

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):

foreach (RoomInfo game in PhotonNetwork.GetRoomList())


{
GUILayout.Label(game.name + " " + game.playerCount + "/" + game.
maxPlayers);
}

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.

Advanced Matchmaking & Room Properties

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 and the Lobby

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.

string[] roomPropsInLobby = { "map", "ai" };


Hashtable customRoomProperties = new Hashtable() { { "map", 1 } };
CreateRoom(roomName, true, true, 4, customRoomProperties, roomPropsInLobby);

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.

Filtering Room Properties in Join Random

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.

Hashtable expectedCustomRoomProperties = new Hashtable() { { "map", 1 } };


JoinRandomRoom(expectedCustomRoomProperties, 4);

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.

Sending messages in game rooms

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.

Using Groups in PUN

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

void OnPhotonSerializeView(PhotonStream stream,


PhotonMessageInfo info)
{
if (stream.isWriting)
{
//We own this player: send the others our data
stream.SendNext((int)controllerScript._characterState);
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
}
else
{
//Network player, receive data
controllerScript._characterState = (CharacterState)(int)stream.
ReceiveNext();
correctPlayerPos = (Vector3)stream.ReceiveNext();
correctPlayerRot = (Quaternion)stream.ReceiveNext();
}
}

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

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.

PhotonView photonView = PhotonView.Get(this);


photonView.RPC("ChatMessage", PhotonTargets.All, "jup", "and jup!");

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));
}

Timing for RPCs and Loading Levels

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

private IEnumerator MoveToGameScene()


{
// Temporary disable processing of futher network messages
PhotonNetwork.isMessageQueueRunning = false;
Application.LoadLevel(levelName);
}

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

Differences to Unity Networking

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.

5. Features & maintenance

• 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

Instantiating objects over the network

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.
}

Gain more control: Manually instantiate

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();

photonView.RPC("SpawnOnNetwork", PhotonTargets.AllBuffered, transform.position,


transform.rotation, id1, PhotonNetwork.player);
}

public Transform playerPrefab; //set this in the inspector

[RPC]
void SpawnOnNetwork(Vector3 pos, Quaternion rot, PhotonViewID id1, PhotonPlayer np)
{
Transform newPlayer = Instantiate(playerPrefab, pos, rot) as Transform;

//Set the PhotonView


PhotonView[] nViews = go.GetComponentsInChildren<PhotonView>();
nViews[0].viewID = id1;
}

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

Views and players

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.

Groups and Scoping

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.

Can I use multiple PhotonViews per GameObject? Why?

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.

Can I use it from Javascript?

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

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

Gui for Network Simulation

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.

• "Jit" slider: Adds a random delay of "up to X milliseconds" per message.

• "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

Gui for Network Statistics

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"

• traffic: Show lower level network traffic (bytes per direction)

• health: Show timing of sending, dispatches and their longest gaps

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.

Button "To Log"

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

Button "Stats On" (Enabling Traffic Stats)

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

What is the public PUN api

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

Here is a list of all modules:


Optional Gui Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Public API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
20 Module Index

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 7

Namespace Index

7.1 Packages

Here are the packages with brief descriptions (if available):


Photon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
22 Namespace Index

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 8

Hierarchical Index

8.1 Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically:


ActorProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
AuthenticationValues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
ErrorCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
EventCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
FriendInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
GameProperties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
MonoBehaviour
Photon.MonoBehaviour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
PhotonView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
PhotonLagSimulationGui . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
MonoBehaviour
PhotonStatsGui . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
PingCloudRegions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
OperationCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
ParameterCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
PBitStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
PhotonMessageInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
PhotonNetwork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
PhotonPlayer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
PhotonStream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
RoomInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Room . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
ScriptableObject
ServerSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
24 Hierarchical Index

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 9

Class Index

9.1 Class List

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

10.1 File List

Here is a list of all files with brief descriptions:


Photon Unity Networking/Plugins/PhotonNetwork/CustomTypes.cs . . . . . . . . . . . . . . . . . . . . 99
Photon Unity Networking/Plugins/PhotonNetwork/Enums.cs . . . . . . . . . . . . . . . . . . . . . . . . 99
Photon Unity Networking/Plugins/PhotonNetwork/Extensions.cs . . . . . . . . . . . . . . . . . . . . . 100
Photon Unity Networking/Plugins/PhotonNetwork/FriendInfo.cs . . . . . . . . . . . . . . . . . . . . . . 101
Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs . . . . . . . . . . . . . . . . . 101
Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs . . . . . . . . . . . . . . . . . . . 102
Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs . . . . . . . . . . . . . . . . . . . 103
Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs . . . . . . . . . . . . . . . . . . . 103
Photon Unity Networking/Plugins/PhotonNetwork/PhotonLagSimulationGui.cs . . . . . . . . . . . . . . 104
Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs . . . . . . . . . . . . . . . . . . . 104
Photon Unity Networking/Plugins/PhotonNetwork/PhotonPlayer.cs . . . . . . . . . . . . . . . . . . . . 104
Photon Unity Networking/Plugins/PhotonNetwork/PhotonStatsGui.cs . . . . . . . . . . . . . . . . . . . 105
Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs . . . . . . . . . . . . . . . . . . . . . 105
Photon Unity Networking/Plugins/PhotonNetwork/PingCloudRegions.cs . . . . . . . . . . . . . . . . . 106
Photon Unity Networking/Plugins/PhotonNetwork/Room.cs . . . . . . . . . . . . . . . . . . . . . . . . 106
Photon Unity Networking/Plugins/PhotonNetwork/RoomInfo.cs . . . . . . . . . . . . . . . . . . . . . . 106
Photon Unity Networking/Plugins/PhotonNetwork/RPC.cs . . . . . . . . . . . . . . . . . . . . . . . . . 106
Photon Unity Networking/Plugins/PhotonNetwork/RpcIndexComponent.cs . . . . . . . . . . . . . . . . 106
Photon Unity Networking/Plugins/PhotonNetwork/ServerSettings.cs . . . . . . . . . . . . . . . . . . . 106
28 File Index

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 11

Module Documentation

11.1 Optional Gui Elements

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.

11.1.1 Detailed Description

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

11.2 Public API

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.

11.2.1 Detailed Description

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.

11.2.2 Enumeration Type Documentation

11.2.2.1 enum DisconnectCause

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.

11.2.2.2 enum PeerState

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

11.2.2.3 enum PhotonLogLevel

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

11.2.2.4 enum PhotonNetworkingMessage

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).

11.2.2.5 enum PhotonTargets

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

12.1 Package Photon

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

13.1 ActorProperties Class Reference

Class for constants. These (byte) values define "well known" properties for an Actor / Player. Pun uses these
constants internally.

Public Attributes

• const byte PlayerName = 255


(255) Name of a player/actor.

13.1.1 Detailed Description

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.

13.1.2 Member Data Documentation

13.1.2.1 const byte ActorProperties.PlayerName = 255

(255) Name of a player/actor.


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.2 AuthenticationValues Class Reference

Container for "Custom Authentication" values in Photon (default: user and token). Set AuthParameters before
connecting - all else is handled.

Public Member Functions

• virtual void SetAuthPostData (string stringData)


Sets the data to be passed-on to the auth service via POST.
38 Class Documentation

• virtual void SetAuthPostData (byte[ ] byteData)


Sets the data to be passed-on to the auth service via POST.
• virtual void SetAuthParameters (string user, string token)
Creates the default parameter string from a user and token value, escaping both. Alternatively set AuthParameters
yourself.
• override string ToString ()

Public Attributes

• CustomAuthenticationType AuthType = CustomAuthenticationType.Custom


The type of custom authentication provider that should be used. Currently only "Custom" or "None" (turns this off).
• string AuthParameters
This string must contain any (http get) parameters expected by the used authentication service. By default, username
and token.
• string Secret
After initial authentication, Photon provides a secret for this client / user, which is subsequently used as (cached)
validation.

Properties

• object AuthPostData [get, set]


Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters).

13.2.1 Detailed Description

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

13.2.2 Member Function Documentation

13.2.2.1 virtual void AuthenticationValues.SetAuthParameters ( string user, string token ) [virtual]

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.

13.2.2.2 virtual void AuthenticationValues.SetAuthPostData ( string stringData ) [virtual]

Sets the data to be passed-on to the auth service via POST.

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.

13.2.2.3 virtual void AuthenticationValues.SetAuthPostData ( byte[ ] byteData ) [virtual]

Sets the data to be passed-on to the auth service via POST.


Parameters
byteData Binary token / auth-data to pass on.

13.2.2.4 override string AuthenticationValues.ToString ( )

13.2.3 Member Data Documentation

13.2.3.1 string AuthenticationValues.AuthParameters

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).

13.2.3.2 CustomAuthenticationType AuthenticationValues.AuthType = CustomAuthenticationType.Custom

The type of custom authentication provider that should be used. Currently only "Custom" or "None" (turns this off).

13.2.3.3 string AuthenticationValues.Secret

After initial authentication, Photon provides a secret for this client / user, which is subsequently used as (cached)
validation.

13.2.4 Property Documentation

13.2.4.1 object AuthenticationValues.AuthPostData [get], [set]

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:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.3 ErrorCode Class Reference

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

• const int OperationNotAllowedInCurrentState = -3


(-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).
• const int InvalidOperationCode = -2
(-2) The operation you called is not implemented on the server (application) you connect to. Make sure you run the
fitting applications.
• const int InternalServerError = -1
(-1) Something went wrong in the server. Try to reproduce and contact Exit Games.
• const int InvalidAuthentication = 0x7FFF
(32767) Authentication failed. Possible cause: AppId is unknown to Photon (in cloud service).
• const int GameIdAlreadyExists = 0x7FFF - 1
(32766) GameId (name) already in use (can’t create another). Change name.
• const int GameFull = 0x7FFF - 2
(32765) Game is full. This rarely happens when some player joined the room before your join completed.
• const int GameClosed = 0x7FFF - 3
(32764) Game is closed and can’t be joined. Join another game.
• const int AlreadyMatched = 0x7FFF - 4
• const int ServerFull = 0x7FFF - 5
(32762) Not in use currently.
• const int UserBlocked = 0x7FFF - 6
(32761) Not in use currently.
• const int NoRandomMatchFound = 0x7FFF - 7
(32760) Random matchmaking only succeeds if a room exists thats neither closed nor full. Repeat in a few seconds
or create a new room.
• const int GameDoesNotExist = 0x7FFF - 9
(32758) Join can fail if the room (name) is not existing (anymore). This can happen when players leave while you join.
• const int MaxCcuReached = 0x7FFF - 10
(32757) Authorization on the Photon Cloud failed because the concurrent users (CCU) limit of the app’s subscription
is reached.
• const int InvalidRegion = 0x7FFF - 11
(32756) Authorization on the Photon Cloud failed because the app’s subscription does not allow to use a particular
region’s server.
• const int CustomAuthenticationFailed = 0x7FFF - 12
(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.

13.3.1 Detailed Description

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.

13.3.2 Member Data Documentation

13.3.2.1 const int ErrorCode.AlreadyMatched = 0x7FFF - 4

13.3.2.2 const int ErrorCode.CustomAuthenticationFailed = 0x7FFF - 12

(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

13.3.2.3 const int ErrorCode.GameClosed = 0x7FFF - 3

(32764) Game is closed and can’t be joined. Join another game.

13.3.2.4 const int ErrorCode.GameDoesNotExist = 0x7FFF - 9

(32758) Join can fail if the room (name) is not existing (anymore). This can happen when players leave while you
join.

13.3.2.5 const int ErrorCode.GameFull = 0x7FFF - 2

(32765) Game is full. This rarely happens when some player joined the room before your join completed.

13.3.2.6 const int ErrorCode.GameIdAlreadyExists = 0x7FFF - 1

(32766) GameId (name) already in use (can’t create another). Change name.

13.3.2.7 const int ErrorCode.InternalServerError = -1

(-1) Something went wrong in the server. Try to reproduce and contact Exit Games.

13.3.2.8 const int ErrorCode.InvalidAuthentication = 0x7FFF

(32767) Authentication failed. Possible cause: AppId is unknown to Photon (in cloud service).

13.3.2.9 const int ErrorCode.InvalidOperationCode = -2

(-2) The operation you called is not implemented on the server (application) you connect to. Make sure you run the
fitting applications.

13.3.2.10 const int ErrorCode.InvalidRegion = 0x7FFF - 11

(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.

13.3.2.11 const int ErrorCode.MaxCcuReached = 0x7FFF - 10

(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

13.3.2.12 const int ErrorCode.NoRandomMatchFound = 0x7FFF - 7

(32760) Random matchmaking only succeeds if a room exists thats neither closed nor full. Repeat in a few seconds
or create a new room.

13.3.2.13 const int ErrorCode.Ok = 0

(0) is always "OK", anything else an error or specific situation.

13.3.2.14 const int ErrorCode.OperationNotAllowedInCurrentState = -3

(-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)

13.3.2.15 const int ErrorCode.ServerFull = 0x7FFF - 5

(32762) Not in use currently.

13.3.2.16 const int ErrorCode.UserBlocked = 0x7FFF - 6

(32761) Not in use currently.


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.4 EventCode Class Reference

Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses these constants
internally.

Public Attributes

• const byte GameList = 230


(230) Initial list of RoomInfos (in lobby on Master)
• const byte GameListUpdate = 229
(229) Update of RoomInfos to be merged into "initial" list (in lobby on Master)
• const byte QueueState = 228
(228) Currently not used. State of queueing in case of server-full
• const byte Match = 227
(227) Currently not used. Event for matchmaking
• const byte AppStats = 226
(226) Event with stats about this application (players, rooms, etc)
• const byte AzureNodeInfo = 210
(210) Internally used in case of hosting by Azure
• const byte Join = (byte)LiteEventCode.Join
(255) Event Join: someone joined the game. The new actorNumber is provided as well as the properties of that actor
(if set in OpJoin).

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.4 EventCode Class Reference 43

• const byte Leave = (byte)LiteEventCode.Leave


(254) Event Leave: The player who left the game can be identified by the actorNumber.
• const byte PropertiesChanged = (byte)LiteEventCode.PropertiesChanged
(253) When you call OpSetProperties with the broadcast option "on", this event is fired. It contains the properties
being set.
• const byte SetProperties = (byte)LiteEventCode.PropertiesChanged
(253) When you call OpSetProperties with the broadcast option "on", this event is fired. It contains the properties
being set.

13.4.1 Detailed Description

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.

13.4.2 Member Data Documentation

13.4.2.1 const byte EventCode.AppStats = 226

(226) Event with stats about this application (players, rooms, etc)

13.4.2.2 const byte EventCode.AzureNodeInfo = 210

(210) Internally used in case of hosting by Azure

13.4.2.3 const byte EventCode.GameList = 230

(230) Initial list of RoomInfos (in lobby on Master)

13.4.2.4 const byte EventCode.GameListUpdate = 229

(229) Update of RoomInfos to be merged into "initial" list (in lobby on Master)

13.4.2.5 const byte EventCode.Join = (byte)LiteEventCode.Join

(255) Event Join: someone joined the game. The new actorNumber is provided as well as the properties of that
actor (if set in OpJoin).

13.4.2.6 const byte EventCode.Leave = (byte)LiteEventCode.Leave

(254) Event Leave: The player who left the game can be identified by the actorNumber.

13.4.2.7 const byte EventCode.Match = 227

(227) Currently not used. Event for matchmaking

13.4.2.8 const byte EventCode.PropertiesChanged = (byte)LiteEventCode.PropertiesChanged

(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

13.4.2.9 const byte EventCode.QueueState = 228

(228) Currently not used. State of queueing in case of server-full

13.4.2.10 const byte EventCode.SetProperties = (byte)LiteEventCode.PropertiesChanged

(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:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.5 Extensions Class Reference

This static class defines some useful extension methods for several existing classes (e.g. Vector3, float and others).

Static Public Member Functions

• static PhotonView[ ] GetPhotonViewsInChildren (this UnityEngine.GameObject go)


• static PhotonView GetPhotonView (this UnityEngine.GameObject go)
• static bool AlmostEquals (this Vector3 target, Vector3 second, float sqrMagnitudePrecision)
compares the squared magnitude of target - second to given float value
• static bool AlmostEquals (this Vector2 target, Vector2 second, float sqrMagnitudePrecision)
compares the squared magnitude of target - second to given float value
• static bool AlmostEquals (this Quaternion target, Quaternion second, float maxAngle)
compares the angle between target and second to given float value
• static bool AlmostEquals (this float target, float second, float floatDiff)
compares two floats and returns true of their difference is less than floatDiff
• static void Merge (this IDictionary target, IDictionary addHash)
Merges all keys from addHash into the target. Adds new keys and updates the values of existing keys in target.
• static void MergeStringKeys (this IDictionary target, IDictionary addHash)
Merges keys of type string to target Hashtable.
• static string ToStringFull (this IDictionary origin)
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.
• static Hashtable StripToStringKeys (this IDictionary original)
This method copies all string-typed keys of the original into a new Hashtable.
• static void StripKeysWithNullValues (this IDictionary original)
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!
• static bool Contains (this int[ ] target, int nr)
Checks if a particular integer value is in an int-array.

13.5.1 Detailed Description

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 Member Function Documentation

13.5.2.1 static bool Extensions.AlmostEquals ( this Vector3 target, Vector3 second, float sqrMagnitudePrecision )
[static]

compares the squared magnitude of target - second to given float value

13.5.2.2 static bool Extensions.AlmostEquals ( this Vector2 target, Vector2 second, float sqrMagnitudePrecision )
[static]

compares the squared magnitude of target - second to given float value

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

13.5.2.5 static bool Extensions.Contains ( this int[ ] target, int nr ) [static]

Checks if a particular integer value is in an int-array.


This might be useful to look up if a particular actorNumber is in the list of players of a room.
Parameters
target The array of ints to check.
nr The number to lookup in target.

Returns

True if nr was found in target.

13.5.2.6 static PhotonView Extensions.GetPhotonView ( this UnityEngine.GameObject go ) [static]

13.5.2.7 static PhotonView [ ] Extensions.GetPhotonViewsInChildren ( this UnityEngine.GameObject go ) [static]

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]

Merges keys of type string to target Hashtable.


Does not remove keys from target (so non-string keys CAN be in target if they were before).

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.

13.5.2.10 static void Extensions.StripKeysWithNullValues ( this IDictionary original ) [static]

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.

13.5.2.11 static Hashtable Extensions.StripToStringKeys ( this IDictionary original ) [static]

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

New Hashtable containing only string-typed keys of the original.

13.5.2.12 static string Extensions.ToStringFull ( this IDictionary origin ) [static]

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

String of the content of the IDictionary.

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/Extensions.cs

13.6 FriendInfo Class Reference

Used to store info about a friend’s online state and in which room he/she is.

Public Member Functions

• override string ToString ()

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.7 GameProperties Class Reference 47

Properties

• string Name [get, set]


• bool IsOnline [get, set]
• string Room [get, set]
• bool IsInRoom [get]

13.6.1 Detailed Description

Used to store info about a friend’s online state and in which room he/she is.

13.6.2 Member Function Documentation

13.6.2.1 override string FriendInfo.ToString ( )

13.6.3 Property Documentation

13.6.3.1 bool FriendInfo.IsInRoom [get]

13.6.3.2 bool FriendInfo.IsOnline [get], [set]

13.6.3.3 string FriendInfo.Name [get], [set]

13.6.3.4 string FriendInfo.Room [get], [set]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/FriendInfo.cs

13.7 GameProperties Class Reference

Class for constants. These (byte) values are for "well known" room/game properties used in Photon Loadbalancing.
Pun uses these constants internally.

Public Attributes

• const byte MaxPlayers = 255


(255) Max number of players that "fit" into this room. 0 is for "unlimited".
• const byte IsVisible = 254
(254) Makes this room listed or not in the lobby on master.
• const byte IsOpen = 253
(253) Allows more players to join a room (or not).
• const byte PlayerCount = 252
(252) Current count of players in the room. Used only in the lobby on master.
• const byte Removed = 251
(251) True if the room is to be removed from room listing (used in update to room list in lobby on master)
• const byte PropsListedInLobby = 250
(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.
• const byte CleanupCacheOnLeave = 249
Equivalent of Operation Join parameter CleanupCacheOnLeave.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
48 Class Documentation

13.7.1 Detailed Description

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.

13.7.2 Member Data Documentation

13.7.2.1 const byte GameProperties.CleanupCacheOnLeave = 249

Equivalent of Operation Join parameter CleanupCacheOnLeave.

13.7.2.2 const byte GameProperties.IsOpen = 253

(253) Allows more players to join a room (or not).

13.7.2.3 const byte GameProperties.IsVisible = 254

(254) Makes this room listed or not in the lobby on master.

13.7.2.4 const byte GameProperties.MaxPlayers = 255

(255) Max number of players that "fit" into this room. 0 is for "unlimited".

13.7.2.5 const byte GameProperties.PlayerCount = 252

(252) Current count of players in the room. Used only in the lobby on master.

13.7.2.6 const byte GameProperties.PropsListedInLobby = 250

(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.

13.7.2.7 const byte GameProperties.Removed = 251

(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:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.8 Photon.MonoBehaviour Class Reference

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

• PhotonView photonView [get]


• new PhotonView networkView [get]

13.8.1 Detailed Description

This class adds the property photonView, while logging a warning when your game still uses the networkView.

13.8.2 Property Documentation

13.8.2.1 new PhotonView Photon.MonoBehaviour.networkView [get]

13.8.2.2 PhotonView Photon.MonoBehaviour.photonView [get]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs

13.9 OperationCode Class Reference

Class for constants. Contains operation codes. Pun uses these constants internally.

Public Attributes

• const byte Authenticate = 230


(230) Authenticates this peer and connects to a virtual application
• const byte JoinLobby = 229
(229) Joins lobby (on master)
• const byte LeaveLobby = 228
(228) Leaves lobby (on master)
• const byte CreateGame = 227
(227) Creates a game (or fails if name exists)
• const byte JoinGame = 226
(226) Join game (by name)
• const byte JoinRandomGame = 225
(225) Joins random game (on master)
• const byte Leave = (byte)LiteOpCode.Leave
(254) Code for OpLeave, to get out of a room.
• const byte RaiseEvent = (byte)LiteOpCode.RaiseEvent
(253) Raise event (in a room, for other actors/players)

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
50 Class Documentation

• const byte SetProperties = (byte)LiteOpCode.SetProperties


(252) Set Properties (of room or actor/player)
• const byte GetProperties = (byte)LiteOpCode.GetProperties
(251) Get Properties
• const byte ChangeGroups = (byte)LiteOpCode.ChangeGroups
(248) Operation code to change interest groups in Rooms (Lite application and extending ones).
• const byte FindFriends = 222
(222) Request the rooms and online status for a list of friends (by name, which should be unique).

13.9.1 Detailed Description

Class for constants. Contains operation codes. Pun uses these constants internally.

13.9.2 Member Data Documentation

13.9.2.1 const byte OperationCode.Authenticate = 230

(230) Authenticates this peer and connects to a virtual application

13.9.2.2 const byte OperationCode.ChangeGroups = (byte)LiteOpCode.ChangeGroups

(248) Operation code to change interest groups in Rooms (Lite application and extending ones).

13.9.2.3 const byte OperationCode.CreateGame = 227

(227) Creates a game (or fails if name exists)

13.9.2.4 const byte OperationCode.FindFriends = 222

(222) Request the rooms and online status for a list of friends (by name, which should be unique).

13.9.2.5 const byte OperationCode.GetProperties = (byte)LiteOpCode.GetProperties

(251) Get Properties

13.9.2.6 const byte OperationCode.JoinGame = 226

(226) Join game (by name)

13.9.2.7 const byte OperationCode.JoinLobby = 229

(229) Joins lobby (on master)

13.9.2.8 const byte OperationCode.JoinRandomGame = 225

(225) Joins random game (on master)

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.10 ParameterCode Class Reference 51

13.9.2.9 const byte OperationCode.Leave = (byte)LiteOpCode.Leave

(254) Code for OpLeave, to get out of a room.

13.9.2.10 const byte OperationCode.LeaveLobby = 228

(228) Leaves lobby (on master)

13.9.2.11 const byte OperationCode.RaiseEvent = (byte)LiteOpCode.RaiseEvent

(253) Raise event (in a room, for other actors/players)

13.9.2.12 const byte OperationCode.SetProperties = (byte)LiteOpCode.SetProperties

(252) Set Properties (of room or actor/player)


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.10 ParameterCode Class Reference

Class for constants. Codes for parameters of Operations and Events. Pun uses these constants internally.

Public Attributes

• const byte Address = 230


(230) Address of a (game) server to use.
• const byte PeerCount = 229
(229) Count of players in rooms (connected to game servers for this application, used in stats event)
• const byte GameCount = 228
(228) Count of games in this application (used in stats event)
• const byte MasterPeerCount = 227
(227) Count of players on the master server (connected to master server for this application, looking for games, used
in stats event)
• const byte UserId = 225
(225) User’s ID
• const byte ApplicationId = 224
(224) Your application’s ID: a name on your own Photon or a GUID on the Photon Cloud
• const byte Position = 223
(223) Not used (as "Position" currently). If you get queued before connect, this is your position
• const byte MatchMakingType = 223
(223) Modifies the matchmaking algorithm used for OpJoinRandom. Allowed parameter values are defined in enum
MatchmakingMode.
• const byte GameList = 222
(222) List of RoomInfos about open / listed rooms
• const byte Secret = 221
(221) Internally used to establish encryption
• const byte AppVersion = 220
(220) Version of your application
• const byte RoomName = (byte)LiteOpKey.GameId

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

13.10.1 Detailed Description

Class for constants. Codes for parameters of Operations and Events. Pun uses these constants internally.

13.10.2 Member Data Documentation

13.10.2.1 const byte ParameterCode.ActorList = (byte)LiteOpKey.ActorList

(252) Code for list of players in a room. Currently not used.

13.10.2.2 const byte ParameterCode.ActorNr = (byte)LiteOpKey.ActorNr

(254) Code of the Actor of an operation. Used for property get and set.

13.10.2.3 const byte ParameterCode.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.

13.10.2.4 const byte ParameterCode.Address = 230

(230) Address of a (game) server to use.

13.10.2.5 const byte ParameterCode.ApplicationId = 224

(224) Your application’s ID: a name on your own Photon or a GUID on the Photon Cloud

13.10.2.6 const byte ParameterCode.AppVersion = 220

(220) Version of your application

13.10.2.7 const byte ParameterCode.Broadcast = (byte)LiteOpKey.Broadcast

(250) Code for broadcast parameter of OpSetProperties method.

13.10.2.8 const byte ParameterCode.Cache = (byte)LiteOpKey.Cache

(247) Code for caching events while raising them.

13.10.2.9 const byte ParameterCode.CleanupCacheOnLeave = (byte)241

(241) Bool parameter of CreateGame Operation. If true, server cleans up roomcache of leaving players (their
cached events get removed).

13.10.2.10 const byte ParameterCode.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

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
54 Class Documentation

13.10.2.11 const byte ParameterCode.ClientAuthenticationParams = 216

(216) This key’s (string) value provides parameters sent to the custom authentication type/service the client connects
with. Used in OpAuthenticate

13.10.2.12 const byte ParameterCode.ClientAuthenticationType = 217

(217) This key’s (byte) value defines the target custom authentication type/service the client connects with. Used in
OpAuthenticate

13.10.2.13 const byte ParameterCode.Code = (byte)LiteOpKey.Code

(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.

13.10.2.14 const byte ParameterCode.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.

13.10.2.15 const byte ParameterCode.CustomEventContent = (byte)LiteOpKey.Data

(245) Code of data/custom content of an event. Used in OpRaiseEvent.

13.10.2.16 const byte ParameterCode.Data = (byte)LiteOpKey.Data

(245) Code of data of an event. Used in OpRaiseEvent.

13.10.2.17 const byte ParameterCode.FindFriendsRequestList = (byte)1

(1) Used in Op FindFriends request. Value must be string[] of friends to look up.

13.10.2.18 const byte ParameterCode.FindFriendsResponseOnlineList = (byte)1

(1) Used in Op FindFriends response. Contains bool[] list of online states (false if not online).

13.10.2.19 const byte ParameterCode.FindFriendsResponseRoomIdList = (byte)2

(2) Used in Op FindFriends response. Contains string[] of room names ("" where not known or no room joined).

13.10.2.20 const byte ParameterCode.GameCount = 228

(228) Count of games in this application (used in stats event)

13.10.2.21 const byte ParameterCode.GameList = 222

(222) List of RoomInfos about open / listed rooms

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.10 ParameterCode Class Reference 55

13.10.2.22 const byte ParameterCode.GameProperties = (byte)LiteOpKey.GameProperties

(248) Code for property set (Hashtable).

13.10.2.23 const byte ParameterCode.Group = LiteOpKey.Group

(240) Code for "group" operation-parameter (as used in Op RaiseEvent).

13.10.2.24 const byte ParameterCode.MasterPeerCount = 227

(227) Count of players on the master server (connected to master server for this application, looking for games,
used in stats event)

13.10.2.25 const byte ParameterCode.MatchMakingType = 223

(223) Modifies the matchmaking algorithm used for OpJoinRandom. Allowed parameter values are defined in enum
MatchmakingMode.

13.10.2.26 const byte ParameterCode.PeerCount = 229

(229) Count of players in rooms (connected to game servers for this application, used in stats event)

13.10.2.27 const byte ParameterCode.PlayerProperties = (byte)LiteOpKey.ActorProperties

(249) Code for property set (Hashtable).

13.10.2.28 const byte ParameterCode.Position = 223

(223) Not used (as "Position" currently). If you get queued before connect, this is your position

13.10.2.29 const byte ParameterCode.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.

13.10.2.30 const byte ParameterCode.ReceiverGroup = (byte)LiteOpKey.ReceiverGroup

(246) Code to select the receivers of events (used in Lite, Operation RaiseEvent).

13.10.2.31 const byte ParameterCode.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.

13.10.2.32 const byte ParameterCode.RoomName = (byte)LiteOpKey.GameId

(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

13.10.2.33 const byte ParameterCode.Secret = 221

(221) Internally used to establish encryption

13.10.2.34 const byte ParameterCode.TargetActorNr = (byte)LiteOpKey.TargetActorNr

(253) Code of the target Actor of an operation. Used for property set. Is 0 for game

13.10.2.35 const byte ParameterCode.UserId = 225

(225) User’s ID
The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs

13.11 PBitStream Class Reference

Public Member Functions

• 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)

Static Public Member Functions

• static int BytesForBits (int bitCount)

Properties

• int ByteCount [get]


• int BitCount [get, set]
• int Position [get, set]

13.11.1 Constructor & Destructor Documentation

13.11.1.1 PBitStream.PBitStream ( )

13.11.1.2 PBitStream.PBitStream ( int bitCount )

13.11.1.3 PBitStream.PBitStream ( IEnumerable< byte > bytes, int bitCount )

13.11.2 Member Function Documentation

13.11.2.1 void PBitStream.Add ( bool val )

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.12 PhotonLagSimulationGui Class Reference 57

13.11.2.2 static int PBitStream.BytesForBits ( int bitCount ) [static]

13.11.2.3 bool PBitStream.Get ( int bitIndex )

13.11.2.4 bool PBitStream.GetNext ( )

13.11.2.5 void PBitStream.Set ( int bitIndex, bool value )

13.11.2.6 byte [ ] PBitStream.ToBytes ( )

13.11.3 Property Documentation

13.11.3.1 int PBitStream.BitCount [get], [set]

13.11.3.2 int PBitStream.ByteCount [get]

13.11.3.3 int PBitStream.Position [get], [set]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs

13.12 PhotonLagSimulationGui Class Reference

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

Public Member Functions

• void Start ()
• void OnGUI ()

Public Attributes

• Rect WindowRect = new Rect(0, 100, 120, 100)


Positioning rect for window.
• int WindowId = 101
Unity GUI Window ID (must be unique or will cause issues).
• bool Visible = true
Shows or hides GUI (does not affect settings).

Properties

• PhotonPeer Peer [get, set]


The peer currently in use (to set the network simulation).

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
58 Class Documentation

13.12.1 Detailed Description

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.

13.12.2 Member Function Documentation

13.12.2.1 void PhotonLagSimulationGui.OnGUI ( )

13.12.2.2 void PhotonLagSimulationGui.Start ( )

13.12.3 Member Data Documentation

13.12.3.1 bool PhotonLagSimulationGui.Visible = true

Shows or hides GUI (does not affect settings).

13.12.3.2 int PhotonLagSimulationGui.WindowId = 101

Unity GUI Window ID (must be unique or will cause issues).

13.12.3.3 Rect PhotonLagSimulationGui.WindowRect = new Rect(0, 100, 120, 100)

Positioning rect for window.

13.12.4 Property Documentation

13.12.4.1 PhotonPeer PhotonLagSimulationGui.Peer [get], [set]

The peer currently in use (to set the network simulation).


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonLagSimulationGui.cs

13.13 PhotonMessageInfo Class Reference

Container class for info about a particular message, RPC or update.

Public Member Functions

• 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

• double timestamp [get]

13.13.1 Detailed Description

Container class for info about a particular message, RPC or update.

13.13.2 Constructor & Destructor Documentation

13.13.2.1 PhotonMessageInfo.PhotonMessageInfo ( )

Initializes a new instance of the PhotonMessageInfo class. To create an empty messageinfo only!

13.13.2.2 PhotonMessageInfo.PhotonMessageInfo ( PhotonPlayer player, int timestamp, PhotonView view )

13.13.3 Member Function Documentation

13.13.3.1 override string PhotonMessageInfo.ToString ( )

13.13.4 Member Data Documentation

13.13.4.1 PhotonView PhotonMessageInfo.photonView

13.13.4.2 PhotonPlayer PhotonMessageInfo.sender

13.13.5 Property Documentation

13.13.5.1 double PhotonMessageInfo.timestamp [get]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs

13.14 PhotonNetwork Class Reference

The main class to use the PhotonNetwork plugin. This class is static.

Static Public Member Functions

• static bool SetMasterClient (PhotonPlayer player)


Allows the current Master Client to assign someone else as MC - custom selection should pick the same user on any
client.
• static void NetworkStatisticsReset ()
Resets the traffic stats and re-enables them.
• static string NetworkStatisticsToString ()
Only available when NetworkStatisticsEnabled was used to gather some stats.
• static void InternalCleanPhotonMonoFromSceneIfStuck ()
Internally used by Editor scripts, called on Hierarchy change (includes scene save) to remove surplus hidden Photon-
Handlers.
• static void ConnectUsingSettings (string gameVersion)

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

• const string versionPUN = "1.24"


Version number of PUN. Also used in GameVersion to separate client version from each other.
• const string serverSettingsAssetFile = "PhotonServerSettings"
Name of the PhotonServerSettings file (used to load and by PhotonEditor to save new files).
• const string serverSettingsAssetPath = "Assets/Photon Unity Networking/Resources/" + PhotonNetwork.-
serverSettingsAssetFile + ".asset"
Path to the PhotonServerSettings file (used by PhotonEditor).

Static Public Attributes

• static readonly int MAX_VIEW_IDS = 1000


The maximum amount of assigned PhotonViews PER player (or scene). See the documentation on how to raise this
limitation
• static ServerSettings PhotonServerSettings = (ServerSettings)Resources.Load(PhotonNetwork.server-
SettingsAssetFile, typeof(ServerSettings))
Serialized server settings, written by the Setup Wizard for use in ConnectUsingSettings.
• static float precisionForVectorSynchronization = 0.000099f
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.
• static float precisionForQuaternionSynchronization = 1.0f
The minimum angle that a rotation needs to change before we send it via a PhotonView’s OnSerialize/Observing-
Component
• static float precisionForFloatSynchronization = 0.01f
The minimum difference between floats before we send it via a PhotonView’s OnSerialize/ObservingComponent
• static PhotonLogLevel logLevel = PhotonLogLevel.ErrorsOnly
Network log level. Controls how verbose PUN is.
• static bool UsePrefabCache = true
While enabled (true), Instantiate uses PhotonNetwork.PrefabCache to keep game objects in memory (improving
instantiation of the same prefab).
• static Dictionary< string,
GameObject > PrefabCache = new Dictionary<string, GameObject>()
Keeps references to GameObjects for frequent instantiation (out of memory instead of loading the Resources).
• static HashSet< GameObject > SendMonoMessageTargets
If not null, this is the (exclusive) list of GameObjects that get called by PUN SendMonoMessage().

Properties

• static string ServerAddress [get]


Currently used server address (no matter if master or game server).
• static bool connected [get]
Are we connected to the photon server (can be IN or OUTSIDE a room)
• static ConnectionState connectionState [get]
Simplified connection state
• static PeerState connectionStateDetailed [get]
Detailed connection state (ignorant of PUN, so it can be "disconnected" while switching servers).
• static AuthenticationValues AuthValues [get, set]
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.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 63

• static Room room [get]


Get the room we’re currently in. Null if we aren’t in any room.
• static PhotonPlayer player [get]
The local PhotonPlayer. Always available and represents this player. CustomProperties can be set before entering a
room and will be synced as well.
• static PhotonPlayer masterClient [get]
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.
• static string playerName [get, set]
This local player’s name.
• static PhotonPlayer[ ] playerList [get]
The full PhotonPlayer list, including the local player.
• static PhotonPlayer[ ] otherPlayers [get]
The other PhotonPlayers, not including our local player.
• static List< FriendInfo > Friends [get, set]
Read-only list of friends, their online status and the room they are in. Null until initialized by a FindFriends call.
• static int FriendsListAge [get]
Age of friend list info (in milliseconds). It’s 0 until a friend list is fetched.
• static bool offlineMode [get, set]
Offline mode can be set to re-use your multiplayer code in singleplayer game modes. When this is on PhotonNetwork
will not create any connections and there is near to no overhead. Mostly usefull for reusing RPC’s and Photon-
Network.Instantiate
• static int maxConnections [get, set]
The maximum number of players for a room. Better: Set it in CreateRoom. If no room is opened, this will return 0.
• static bool automaticallySyncScene [get, set]
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.
• static bool autoCleanUpPlayerObjects [get, set]
This setting defines if players in a room should destroy a leaving player’s instantiated GameObjects and PhotonViews.
• static bool autoJoinLobby [get, set]
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.
• static bool insideLobby [get]
Returns true when we are connected to Photon and in the lobby state
• static int sendRate [get, set]
Defines how many times per second PhotonNetwork should send a package. If you change this, do not forget to also
change ’sendRateOnSerialize’.
• static int sendRateOnSerialize [get, set]
Defines how many times per second OnPhotonSerialize should be called on PhotonViews.
• static bool isMessageQueueRunning [get, set]
Can be used to pause dispatching of incoming evtents (RPCs, Instantiates and anything else incoming).
• static int unreliableCommandsLimit [get, set]
Used once per dispatch to limit unreliable commands per channel (so after a pause, many channels can still cause a
lot of unreliable commands)
• static double time [get]
Photon network time, synched with the server
• static bool isMasterClient [get]
Are we the master client?
• static bool isNonMasterClientInRoom [get]
True if we are in a room (client) and NOT the room’s masterclient
• static int countOfPlayersOnMaster [get]

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).

13.14.1 Detailed Description

The main class to use the PhotonNetwork plugin. This class is static.

13.14.2 Member Function Documentation

13.14.2.1 static int PhotonNetwork.AllocateViewID ( ) [static]

Allocates a viewID that’s valid for the current/local player.

Returns

A viewID that can be used for a new PhotonView.

13.14.2.2 static void PhotonNetwork.CloseConnection ( PhotonPlayer kickPlayer ) [static]

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:

• Network issues (calls: OnFailedToConnectToPhoton())

• Subscription CCU limit reached (calls: OnConnectionFail() with DisconnectCause.MaxCcuReached. also


calls: OnPhotonMaxCccuReached())

More about the connection limitations: http://doc.exitgames.com/photon-cloud/

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).

13.14.2.4 static void PhotonNetwork.ConnectToBestCloudServer ( string gameVersion ) [static]

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:

• Network issues (calls: OnFailedToConnectToPhoton())

• Invalid region (calls: OnConnectionFail() with DisconnectCause.InvalidRegion)

• Subscription CCU limit reached (calls: OnConnectionFail() with DisconnectCause.MaxCcuReached. also


calls: OnPhotonMaxCccuReached())

More about the connection limitations: http://doc.exitgames.com/photon-cloud


Parameters
gameVersion This client’s version number. Users are separated from each other by gameversion (which
allows you to make breaking changes).

13.14.2.5 static void PhotonNetwork.ConnectUsingSettings ( string gameVersion ) [static]

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:

• Network issues (calls: OnFailedToConnectToPhoton())

• Invalid region (calls: OnConnectionFail() with DisconnectCause.InvalidRegion)

• Subscription CCU limit reached (calls: OnConnectionFail() with DisconnectCause.MaxCcuReached. also


calls: OnPhotonMaxCccuReached())

More about the connection limitations: http://doc.exitgames.com/photon-cloud

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).

13.14.2.6 static void PhotonNetwork.CreateRoom ( string roomName ) [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.

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).

13.14.2.9 static void PhotonNetwork.Destroy ( PhotonView targetView ) [static]

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:

• Removal of the Instantiate call from the server’s room buffer.

• 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 and owned by this client.

• Instantiated objects of players who left the room are controlles by the Master Client.

• Scene-owned game objects are controlled by the Master Client.

Returns

Nothing. Check error debug log for any issues.

13.14.2.10 static void PhotonNetwork.Destroy ( GameObject targetGo ) [static]

Network-Destroy the GameObject, unless it is static or not under this client’s control.
Destroying a networked GameObject includes:

• Removal of the Instantiate call from the server’s room buffer.

• 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 and owned by this client.

• Instantiated objects of players who left the room are controlles by the Master Client.

• Scene-owned game objects are controlled by the Master Client.

Returns

Nothing. Check error debug log for any issues.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
68 Class Documentation

13.14.2.11 static void PhotonNetwork.DestroyAll ( ) [static]

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

Nothing. Check error debug log for any issues.

13.14.2.12 static void PhotonNetwork.DestroyPlayerObjects ( PhotonPlayer targetPlayer ) [static]

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:

• Removal of the Instantiate call from the server’s room buffer.

• 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

Nothing. Check error debug log for any issues.

13.14.2.13 static void PhotonNetwork.DestroyPlayerObjects ( int targetPlayerId ) [static]

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:

• Removal of the Instantiate call from the server’s room buffer.

• 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

Nothing. Check error debug log for any issues.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 69

13.14.2.14 static void PhotonNetwork.Disconnect ( ) [static]

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.

13.14.2.15 static void PhotonNetwork.FetchServerTimestamp ( ) [static]

Refreshes the server timestamp (async operation, takes a roundtrip).


Can be useful if a bad connection made the timestamp unusable or imprecise.

13.14.2.16 static bool PhotonNetwork.FindFriends ( string[ ] friendsToFind ) [static]

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.

13.14.2.17 static int PhotonNetwork.GetPing ( ) [static]

The current roundtrip time to the photon server

Returns

Roundtrip time (to server and back).

13.14.2.18 static RoomInfo [ ] PhotonNetwork.GetRoomList ( ) [static]

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

RoomInfo[] of current rooms in lobby.

13.14.2.19 static void PhotonNetwork.InitializeSecurity ( ) [static]

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

The new instance of a GameObject with initialized PhotonView.

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

The new instance of a GameObject with initialized PhotonView.

13.14.2.22 static GameObject PhotonNetwork.InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion


rotation, int group, object[ ] data ) [static]

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

The new instance of a GameObject with initialized PhotonView.

13.14.2.23 static void PhotonNetwork.InternalCleanPhotonMonoFromSceneIfStuck ( ) [static]

Internally used by Editor scripts, called on Hierarchy change (includes scene save) to remove surplus hidden
PhotonHandlers.

13.14.2.24 static void PhotonNetwork.JoinRandomRoom ( ) [static]

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.

13.14.2.25 static void PhotonNetwork.JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte


expectedMaxPlayers ) [static]

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

13.14.2.26 static void PhotonNetwork.JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte


expectedMaxPlayers, MatchmakingMode matchingType ) [static]

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.

13.14.2.27 static void PhotonNetwork.JoinRoom ( string roomName ) [static]

Join room by roomname and on success calls OnJoinedRoom().


On success, the method OnJoinedRoom() is called on any script. You can implement it to react to joining a room.
JoinRoom fails if the room is either full or no longer available (it might become empty while you attempt to join).
Implement OnPhotonJoinRoomFailed() to get a callback in error case.
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.

13.14.2.28 static void PhotonNetwork.JoinRoom ( string roomName, bool createIfNotExists ) [static]

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().

13.14.2.29 static void PhotonNetwork.LeaveRoom ( ) [static]

Leave the current room

13.14.2.30 static void PhotonNetwork.LoadLevel ( int levelNumber ) [static]

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).

13.14.2.31 static void PhotonNetwork.LoadLevel ( string levelTitle ) [static]

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.

13.14.2.32 static void PhotonNetwork.NetworkStatisticsReset ( ) [static]

Resets the traffic stats and re-enables them.

13.14.2.33 static string PhotonNetwork.NetworkStatisticsToString ( ) [static]

Only available when NetworkStatisticsEnabled was used to gather some stats.

Returns

A string with vital networking statistics.

13.14.2.34 static void PhotonNetwork.OverrideBestCloudServer ( CloudServerRegion region ) [static]

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.

13.14.2.35 static void PhotonNetwork.RefreshCloudServerRating ( ) [static]

Pings all cloud servers again to find the one with best ping (currently).

13.14.2.36 static void PhotonNetwork.RemoveRPCs ( PhotonPlayer targetPlayer ) [static]

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 is the targetPlayer’s client.

• 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.

13.14.2.37 static void PhotonNetwork.RemoveRPCs ( PhotonView targetPhotonView ) [static]

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:

• The targetPhotonView is owned by this client (Instantiated by it).

• 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

13.14.2.38 static void PhotonNetwork.RemoveRPCsInGroup ( int targetGroup ) [static]

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.

13.14.2.39 static void PhotonNetwork.SendOutgoingCommands ( ) [static]

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.

13.14.2.40 static void PhotonNetwork.SetLevelPrefix ( short prefix ) [static]

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

13.14.2.41 static bool PhotonNetwork.SetMasterClient ( PhotonPlayer player ) [static]

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.

13.14.2.42 static void PhotonNetwork.SetPlayerCustomProperties ( Hashtable customProperties ) [static]

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.

13.14.2.43 static void PhotonNetwork.SetReceivingEnabled ( int group, bool enabled ) [static]

Enable/disable receiving on given group (applied to PhotonViews)


Parameters
group The interest group to affect.
enabled Sets if receiving from group to enabled (or not).

13.14.2.44 static void PhotonNetwork.SetSendingEnabled ( int group, bool enabled ) [static]

Enable/disable sending on given group (applied to PhotonViews)

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).

13.14.2.45 static void PhotonNetwork.UnAllocateViewID ( int viewID ) [static]

Unregister a viewID (of manually instantiated and destroyed networked objects).


Parameters
viewID A viewID manually allocated by this player.

13.14.3 Member Data Documentation

13.14.3.1 PhotonLogLevel PhotonNetwork.logLevel = PhotonLogLevel.ErrorsOnly [static]

Network log level. Controls how verbose PUN is.

13.14.3.2 readonly int PhotonNetwork.MAX_VIEW_IDS = 1000 [static]

The maximum amount of assigned PhotonViews PER player (or scene). See the documentation on how to raise
this limitation

13.14.3.3 ServerSettings PhotonNetwork.PhotonServerSettings = (ServerSettings)Resources.Load(PhotonNetwork.-


serverSettingsAssetFile, typeof(ServerSettings)) [static]

Serialized server settings, written by the Setup Wizard for use in ConnectUsingSettings.

13.14.3.4 float PhotonNetwork.precisionForFloatSynchronization = 0.01f [static]

The minimum difference between floats before we send it via a PhotonView’s OnSerialize/ObservingComponent

13.14.3.5 float PhotonNetwork.precisionForQuaternionSynchronization = 1.0f [static]

The minimum angle that a rotation needs to change before we send it via a PhotonView’s OnSerialize/Observing-
Component

13.14.3.6 float PhotonNetwork.precisionForVectorSynchronization = 0.000099f [static]

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.

13.14.3.7 Dictionary<string, GameObject> PhotonNetwork.PrefabCache = new Dictionary<string, GameObject>()


[static]

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

13.14.3.8 HashSet<GameObject> PhotonNetwork.SendMonoMessageTargets [static]

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.

13.14.3.9 const string PhotonNetwork.serverSettingsAssetFile = "PhotonServerSettings"

Name of the PhotonServerSettings file (used to load and by PhotonEditor to save new files).

13.14.3.10 const string PhotonNetwork.serverSettingsAssetPath = "Assets/Photon Unity Networking/Resources/" +


PhotonNetwork.serverSettingsAssetFile + ".asset"

Path to the PhotonServerSettings file (used by PhotonEditor).

13.14.3.11 bool PhotonNetwork.UsePrefabCache = true [static]

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.

13.14.3.12 const string PhotonNetwork.versionPUN = "1.24"

Version number of PUN. Also used in GameVersion to separate client version from each other.

13.14.4 Property Documentation

13.14.4.1 AuthenticationValues PhotonNetwork.AuthValues [static], [get], [set]

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

13.14.4.2 bool PhotonNetwork.autoCleanUpPlayerObjects [static], [get], [set]

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

Once a room is created, this setting can’t be changed anymore.


Enabled by default.

13.14.4.3 bool PhotonNetwork.autoJoinLobby [static], [get], [set]

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).

13.14.4.4 bool PhotonNetwork.automaticallySyncScene [static], [get], [set]

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.

13.14.4.5 bool PhotonNetwork.connected [static], [get]

Are we connected to the photon server (can be IN or OUTSIDE a room)

13.14.4.6 ConnectionState PhotonNetwork.connectionState [static], [get]

Simplified connection state

13.14.4.7 PeerState PhotonNetwork.connectionStateDetailed [static], [get]

Detailed connection state (ignorant of PUN, so it can be "disconnected" while switching servers).

13.14.4.8 int PhotonNetwork.countOfPlayers [static], [get]

The count of players currently using this application. This is updated on the MasterServer (only) in 5sec intervals (if
any count changed).

13.14.4.9 int PhotonNetwork.countOfPlayersInRooms [static], [get]

The count of players currently inside a room This is updated on the MasterServer (only) in 5sec intervals (if any
count changed).

13.14.4.10 int PhotonNetwork.countOfPlayersOnMaster [static], [get]

The count of players currently looking for a room. This is updated on the MasterServer (only) in 5sec intervals (if
any count changed).

13.14.4.11 int PhotonNetwork.countOfRooms [static], [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).

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.14 PhotonNetwork Class Reference 79

13.14.4.12 List<FriendInfo> PhotonNetwork.Friends [static], [get], [set]

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).

13.14.4.13 int PhotonNetwork.FriendsListAge [static], [get]

Age of friend list info (in milliseconds). It’s 0 until a friend list is fetched.

13.14.4.14 bool PhotonNetwork.insideLobby [static], [get]

Returns true when we are connected to Photon and in the lobby state

13.14.4.15 bool PhotonNetwork.isMasterClient [static], [get]

Are we the master client?

13.14.4.16 bool PhotonNetwork.isMessageQueueRunning [static], [get], [set]

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.

13.14.4.17 bool PhotonNetwork.isNonMasterClientInRoom [static], [get]

True if we are in a room (client) and NOT the room’s masterclient

13.14.4.18 PhotonPlayer PhotonNetwork.masterClient [static], [get]

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.

13.14.4.19 int PhotonNetwork.maxConnections [static], [get], [set]

The maximum number of players for a room. Better: Set it in CreateRoom. If no room is opened, this will return 0.

13.14.4.20 bool PhotonNetwork.NetworkStatisticsEnabled [static], [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.
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

13.14.4.21 bool PhotonNetwork.offlineMode [static], [get], [set]

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

13.14.4.22 PhotonPlayer [ ] PhotonNetwork.otherPlayers [static], [get]

The other PhotonPlayers, not including our local player.

13.14.4.23 PhotonPlayer PhotonNetwork.player [static], [get]

The local PhotonPlayer. Always available and represents this player. CustomProperties can be set before entering
a room and will be synced as well.

13.14.4.24 PhotonPlayer [ ] PhotonNetwork.playerList [static], [get]

The full PhotonPlayer list, including the local player.

13.14.4.25 string PhotonNetwork.playerName [static], [get], [set]

This local player’s name.


Setting the name will automatically send it, if connected. Setting null, won’t change the name.

13.14.4.26 int PhotonNetwork.ResentReliableCommands [static], [get]

Count of commands that got repeated (due to local repeat-timing before an ACK was received).

13.14.4.27 Room PhotonNetwork.room [static], [get]

Get the room we’re currently in. Null if we aren’t in any room.

13.14.4.28 int PhotonNetwork.sendRate [static], [get], [set]

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.

13.14.4.29 int PhotonNetwork.sendRateOnSerialize [static], [get], [set]

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.

13.14.4.30 string PhotonNetwork.ServerAddress [static], [get]

Currently used server address (no matter if master or game server).

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.15 PhotonPlayer Class Reference 81

13.14.4.31 double PhotonNetwork.time [static], [get]

Photon network time, synched with the server


v1.3: This time reflects milliseconds since start of the server, cut down to 4 bytes. It will overflow every 49 days
from a high value to 0. We do not (yet) compensate this overflow. Master- and Game-Server will have different time
values. v1.10: Fixed issues with precision for high server-time values. This should update with 15ms precision by
default.

13.14.4.32 int PhotonNetwork.unreliableCommandsLimit [static], [get], [set]

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:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs

13.15 PhotonPlayer Class Reference

Summarizes a "player" within a room, identified (in that room) by actorID.

Public Member Functions

• PhotonPlayer (bool isLocal, int actorID, string name)


Creates a PhotonPlayer instance.
• override string ToString ()
Gives the name.
• override bool Equals (object p)
Makes PhotonPlayer comparable
• override int GetHashCode ()
• void SetCustomProperties (Hashtable propertiesToSet)
Updates and synchronizes the named properties of this Player with the values of propertiesToSet.

Static Public Member Functions

• static PhotonPlayer Find (int ID)


Try to get a specific player by id.

Public Attributes

• readonly bool isLocal = false


Only one player is controlled by each client. Others are not local.

Protected Member Functions

• PhotonPlayer (bool isLocal, int actorID, Hashtable properties)


Internally used to create players from event Join

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).

13.15.1 Detailed Description

Summarizes a "player" within a room, identified (in that room) by actorID.


Each player has an actorId (or ID), valid for that room. It’s -1 until it’s assigned by server. Each client can set it’s
player’s custom properties with SetCustomProperties, even before being in a room. They are synced when joining
a room.

13.15.2 Constructor & Destructor Documentation

13.15.2.1 PhotonPlayer.PhotonPlayer ( bool isLocal, int actorID, string name )

Creates a PhotonPlayer instance.


Parameters
isLocal If this is the local peer’s player (or a remote one).
actorID ID or ActorNumber of this player in the current room (a shortcut to identify each player in
room)
name Name of the player (a "well known property").

13.15.2.2 PhotonPlayer.PhotonPlayer ( bool isLocal, int actorID, Hashtable properties ) [protected]

Internally used to create players from event Join

13.15.3 Member Function Documentation

13.15.3.1 override bool PhotonPlayer.Equals ( object p )

Makes PhotonPlayer comparable

13.15.3.2 static PhotonPlayer PhotonPlayer.Find ( int ID ) [static]

Try to get a specific player by id.


Parameters

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.

13.15.3.3 override int PhotonPlayer.GetHashCode ( )

13.15.3.4 void PhotonPlayer.SetCustomProperties ( Hashtable propertiesToSet )

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.

13.15.3.5 override string PhotonPlayer.ToString ( )

Gives the name.

13.15.4 Member Data Documentation

13.15.4.1 readonly bool PhotonPlayer.isLocal = false

Only one player is controlled by each client. Others are not local.

13.15.5 Property Documentation

13.15.5.1 Hashtable PhotonPlayer.allProperties [get]

Creates a Hashtable with all properties (custom and "well known" ones).
If used more often, this should be cached.

13.15.5.2 Hashtable PhotonPlayer.customProperties [get], [set]

Read-only cache for custom properties of player. Set via Player.SetCustomProperties.


Don’t modify the content of this Hashtable. Use SetCustomProperties and the properties of this class to modify
values. When you use those, the client will sync values with the server.

13.15.5.3 int PhotonPlayer.ID [get]

This player’s actorID

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
84 Class Documentation

13.15.5.4 bool PhotonPlayer.isMasterClient [get]

The player with the lowest actorID is the master and could be used for special tasks.

13.15.5.5 string PhotonPlayer.name [get], [set]

Nickname of this player.


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonPlayer.cs

13.16 PhotonStatsGui Class Reference

Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.
Inheritance diagram for PhotonStatsGui:

MonoBehaviour

PhotonStatsGui

Public Member Functions

• void Start ()
• void Update ()
Checks for shift+tab input combination (to toggle statsOn).
• void OnGUI ()
• void TrafficStatsWindow (int windowID)

Public Attributes

• bool statsWindowOn = true


Shows or hides GUI (does not affect if stats are collected).
• bool statsOn = true
Option to turn collecting stats on or off (used in Update()).
• bool healthStatsVisible
Shows additional "health" values of connection.
• bool trafficStatsOn
Shows additional "lower level" traffic stats.
• bool buttonsOn
Show buttons to control stats and reset them.
• Rect statsRect = new Rect(0, 100, 200, 50)
Positioning rect for window.
• int WindowId = 100
Unity GUI Window ID (must be unique or will cause issues).

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.16 PhotonStatsGui Class Reference 85

13.16.1 Detailed Description

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).

13.16.2 Member Function Documentation

13.16.2.1 void PhotonStatsGui.OnGUI ( )

13.16.2.2 void PhotonStatsGui.Start ( )

13.16.2.3 void PhotonStatsGui.TrafficStatsWindow ( int windowID )

13.16.2.4 void PhotonStatsGui.Update ( )

Checks for shift+tab input combination (to toggle statsOn).

13.16.3 Member Data Documentation

13.16.3.1 bool PhotonStatsGui.buttonsOn

Show buttons to control stats and reset them.

13.16.3.2 bool PhotonStatsGui.healthStatsVisible

Shows additional "health" values of connection.

13.16.3.3 bool PhotonStatsGui.statsOn = true

Option to turn collecting stats on or off (used in Update()).

13.16.3.4 Rect PhotonStatsGui.statsRect = new Rect(0, 100, 200, 50)

Positioning rect for window.

13.16.3.5 bool PhotonStatsGui.statsWindowOn = true

Shows or hides GUI (does not affect if stats are collected).

13.16.3.6 bool PhotonStatsGui.trafficStatsOn

Shows additional "lower level" traffic stats.

13.16.3.7 int PhotonStatsGui.WindowId = 100

Unity GUI Window ID (must be unique or will cause issues).


The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonStatsGui.cs

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
86 Class Documentation

13.17 PhotonStream Class Reference

This "container" class is used to carry your data as written by OnPhotonSerializeView.

Public Member Functions

• PhotonStream (bool write, object[ ] incomingData)


• object ReceiveNext ()
• void SendNext (object obj)
• object[ ] ToArray ()
• void Serialize (ref bool myBool)
• void Serialize (ref int myInt)
• void Serialize (ref string value)
• void Serialize (ref char value)
• void Serialize (ref short value)
• void Serialize (ref float obj)
• void Serialize (ref PhotonPlayer obj)
• void Serialize (ref Vector3 obj)
• void Serialize (ref Vector2 obj)
• void Serialize (ref Quaternion obj)

Properties

• bool isWriting [get]


• bool isReading [get]
• int Count [get]

13.17.1 Detailed Description

This "container" class is used to carry your data as written by OnPhotonSerializeView.

See Also

PhotonNetworkingMessage

13.17.2 Constructor & Destructor Documentation

13.17.2.1 PhotonStream.PhotonStream ( bool write, object[ ] incomingData )

13.17.3 Member Function Documentation

13.17.3.1 object PhotonStream.ReceiveNext ( )

13.17.3.2 void PhotonStream.SendNext ( object obj )

13.17.3.3 void PhotonStream.Serialize ( ref bool myBool )

13.17.3.4 void PhotonStream.Serialize ( ref int myInt )

13.17.3.5 void PhotonStream.Serialize ( ref string value )

13.17.3.6 void PhotonStream.Serialize ( ref char value )

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.18 PhotonView Class Reference 87

13.17.3.7 void PhotonStream.Serialize ( ref short value )

13.17.3.8 void PhotonStream.Serialize ( ref float obj )

13.17.3.9 void PhotonStream.Serialize ( ref PhotonPlayer obj )

13.17.3.10 void PhotonStream.Serialize ( ref Vector3 obj )

13.17.3.11 void PhotonStream.Serialize ( ref Vector2 obj )

13.17.3.12 void PhotonStream.Serialize ( ref Quaternion obj )

13.17.3.13 object [ ] PhotonStream.ToArray ( )

13.17.4 Property Documentation

13.17.4.1 int PhotonStream.Count [get]

13.17.4.2 bool PhotonStream.isReading [get]

13.17.4.3 bool PhotonStream.isWriting [get]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs

13.18 PhotonView Class Reference

PUN’s NetworkView replacement class for networking. Use it like a NetworkView.


Inheritance diagram for PhotonView:

MonoBehaviour

Photon.MonoBehaviour

PhotonView

Public Member Functions

• 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 ()

Static Public Member Functions

• static PhotonView Get (Component component)

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
88 Class Documentation

• static PhotonView Get (GameObject gameObj)


• static PhotonView Find (int viewID)

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

Protected Member Functions

• void ExecuteOnSerialize (PhotonStream pStream, PhotonMessageInfo info)

Properties

• int prefix [get, set]


• object[ ] instantiationData [get, set]
This is the instantiationData that was passed when calling PhotonNetwork.Instantiate∗ (if that was used to spawn this
prefab)
• int viewID [get, set]
• bool isSceneView [get]
True if the PhotonView was loaded with the scene (game object) or instantiated with InstantiateSceneObject.
• PhotonPlayer owner [get]
• int OwnerActorNr [get]
• bool isMine [get]
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

13.18.1 Detailed Description

PUN’s NetworkView replacement class for networking. Use it like a NetworkView.

13.18.2 Member Function Documentation

13.18.2.1 void PhotonView.Awake ( )

Called by Unity on start of the application and does a setup the PhotonView.

13.18.2.2 void PhotonView.ExecuteOnSerialize ( PhotonStream pStream, PhotonMessageInfo info )


[protected]

13.18.2.3 static PhotonView PhotonView.Find ( int viewID ) [static]

13.18.2.4 static PhotonView PhotonView.Get ( Component component ) [static]

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.18 PhotonView Class Reference 89

13.18.2.5 static PhotonView PhotonView.Get ( GameObject gameObj ) [static]

13.18.2.6 void PhotonView.OnApplicationQuit ( )

13.18.2.7 void PhotonView.OnDestroy ( )

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 )

13.18.2.10 override string PhotonView.ToString ( )

13.18.3 Member Data Documentation

13.18.3.1 int PhotonView.group = 0

13.18.3.2 int PhotonView.instantiationId

13.18.3.3 Component PhotonView.observed

13.18.3.4 OnSerializeRigidBody PhotonView.onSerializeRigidBodyOption = OnSerializeRigidBody.All

13.18.3.5 OnSerializeTransform PhotonView.onSerializeTransformOption = OnSerializeTransform.PositionAnd-


Rotation

13.18.3.6 int PhotonView.ownerId

13.18.3.7 int PhotonView.prefixBackup = -1

13.18.3.8 int PhotonView.subId

13.18.3.9 ViewSynchronization PhotonView.synchronization

13.18.4 Property Documentation

13.18.4.1 object [ ] PhotonView.instantiationData [get], [set]

This is the instantiationData that was passed when calling PhotonNetwork.Instantiate∗ (if that was used to spawn
this prefab)

13.18.4.2 bool PhotonView.isMine [get]

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

13.18.4.3 bool PhotonView.isSceneView [get]

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).

13.18.4.4 PhotonPlayer PhotonView.owner [get]

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
90 Class Documentation

13.18.4.5 int PhotonView.OwnerActorNr [get]

13.18.4.6 int PhotonView.prefix [get], [set]

13.18.4.7 int PhotonView.viewID [get], [set]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs

13.19 PingCloudRegions Class Reference

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

Public Member Functions

• IEnumerator PingAllRegions ()

Static Public Member Functions

• static void OverrideRegion (CloudServerRegion region)


• static void RefreshCloudServerRating ()
• static void ConnectToBestRegion (string gameVersion)
• static string ResolveHost (string hostString)
Attempts to resolve a hostname into an IP string or returns empty string if that fails.

Static Public Attributes

• static CloudServerRegion closestRegion = CloudServerRegion.US


• static PingCloudRegions SP

13.19.1 Detailed Description

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.

13.19.2 Member Function Documentation

13.19.2.1 static void PingCloudRegions.ConnectToBestRegion ( string gameVersion ) [static]

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.20 Room Class Reference 91

13.19.2.2 static void PingCloudRegions.OverrideRegion ( CloudServerRegion region ) [static]

13.19.2.3 IEnumerator PingCloudRegions.PingAllRegions ( )

13.19.2.4 static void PingCloudRegions.RefreshCloudServerRating ( ) [static]

13.19.2.5 static string PingCloudRegions.ResolveHost ( string hostString ) [static]

Attempts to resolve a hostname into an IP string or returns empty string if that fails.
Parameters
hostString Hostname to resolve.

Returns

IP string or empty string if resolution fails

13.19.3 Member Data Documentation

13.19.3.1 CloudServerRegion PingCloudRegions.closestRegion = CloudServerRegion.US [static]

13.19.3.2 PingCloudRegions PingCloudRegions.SP [static]

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/PingCloudRegions.cs

13.20 Room Class Reference

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

Public Member Functions

• void SetCustomProperties (Hashtable propertiesToSet)


Updates and synchronizes the named properties of this Room with the values of propertiesToSet.
• void SetPropertiesListedInLobby (string[ ] propsListedInLobby)
Enables you to define the properties available in the lobby if not all properties are needed to pick a room.

Properties

• new int playerCount [get]


Count of players in this room.
• new string name [get, set]

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.

Additional Inherited Members

13.20.1 Detailed Description

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.

13.20.2 Member Function Documentation

13.20.2.1 void Room.SetCustomProperties ( Hashtable propertiesToSet )

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.

13.20.2.2 void Room.SetPropertiesListedInLobby ( string[ ] propsListedInLobby )

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

propsListedIn- An array of custom room property names to forward to the lobby.


Lobby

13.20.3 Property Documentation

13.20.3.1 bool Room.autoCleanUp [get]

Gets if this room uses autoCleanUp to remove all (buffered) RPCs and instantiated GameObjects when a player
leaves.

13.20.3.2 new int Room.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.

13.20.3.3 new string Room.name [get], [set]

The name of a room. Unique identifier (per Loadbalancing group) for a room/match.

13.20.3.4 new bool Room.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.

13.20.3.5 new int Room.playerCount [get]

Count of players in this room.

13.20.3.6 string [ ] Room.propertiesListedInLobby [get], [set]

A list of custom properties that should be forwarded to the lobby and listed there.

13.20.3.7 new bool Room.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.
The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/Room.cs

13.21 RoomInfo Class Reference

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

Public Member Functions

• override bool Equals (object p)


Makes RoomInfo comparable (by name).
• override int GetHashCode ()
Accompanies Equals, using the name’s HashCode as return.
• override string ToString ()
Simple printingin method.

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

• bool removedFromList [get, set]


Used internally in lobby, to mark rooms that are no longer listed.
• Hashtable customProperties [get]
Read-only "cache" of custom properties of a room. Set via Room.SetCustomProperties (not available for RoomInfo
class!).
• string name [get]
The name of a room. Unique identifier (per Loadbalancing group) for a room/match.
• int playerCount [get, set]
Only used internally in lobby, to display number of players in room (while you’re not in).
• bool isLocalClientInside [get, set]
State if the local client is already in the game or still going to join it on gameserver (in lobby always false).
• byte maxPlayers [get]
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.
• bool open [get]
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.
• bool visible [get]
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.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.21 RoomInfo Class Reference 95

13.21.1 Detailed Description

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).

13.21.2 Member Function Documentation

13.21.2.1 override bool RoomInfo.Equals ( object p )

Makes RoomInfo comparable (by name).

13.21.2.2 override int RoomInfo.GetHashCode ( )

Accompanies Equals, using the name’s HashCode as return.

Returns

13.21.2.3 override string RoomInfo.ToString ( )

Simple printingin method.

Returns

String showing the RoomInfo.

13.21.3 Member Data Documentation

13.21.3.1 bool RoomInfo.autoCleanUpField = false [protected]

Backing field for property. False unless the GameProperty is set to true (else it’s not sent).

13.21.3.2 byte RoomInfo.maxPlayersField = 0 [protected]

Backing field for property.

13.21.3.3 string RoomInfo.nameField [protected]

Backing field for property.

13.21.3.4 bool RoomInfo.openField = true [protected]

Backing field for property.

13.21.3.5 bool RoomInfo.visibleField = true [protected]

Backing field for property.

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
96 Class Documentation

13.21.4 Property Documentation

13.21.4.1 Hashtable RoomInfo.customProperties [get]

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.

13.21.4.2 bool RoomInfo.isLocalClientInside [get], [set]

State if the local client is already in the game or still going to join it on gameserver (in lobby always false).

13.21.4.3 byte RoomInfo.maxPlayers [get]

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.

13.21.4.4 string RoomInfo.name [get]

The name of a room. Unique identifier (per Loadbalancing group) for a room/match.

13.21.4.5 bool RoomInfo.open [get]

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.

13.21.4.6 int RoomInfo.playerCount [get], [set]

Only used internally in lobby, to display number of players in room (while you’re not in).

13.21.4.7 bool RoomInfo.removedFromList [get], [set]

Used internally in lobby, to mark rooms that are no longer listed.

13.21.4.8 bool RoomInfo.visible [get]

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:

• Photon Unity Networking/Plugins/PhotonNetwork/RoomInfo.cs

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
13.22 ServerSettings Class Reference 97

13.22 ServerSettings Class Reference

Collection of connection-relevant settings, used internally by PhotonNetwork.ConnectUsingSettings.


Inheritance diagram for ServerSettings:

ScriptableObject

ServerSettings

Public Types

• enum HostingOption { HostingOption.NotSet, HostingOption.PhotonCloud, HostingOption.SelfHosted,


HostingOption.OfflineMode }

Public Member Functions

• void UseCloud (string cloudAppid, int regionIndex)


• void UseMyServer (string serverAddress, int serverPort, string application)
• override string ToString ()

Static Public Member Functions

• static int FindRegionForServerAddress (string server)


• static string FindServerAddressForRegion (int regionIndex)
• static string FindServerAddressForRegion (CloudServerRegion regionIndex)

Public Attributes

• const string DefaultCloudServerUrl = "app-eu.exitgamescloud.com"


• const string DefaultServerAddress = "127.0.0.1"
• const int DefaultMasterPort = 5055
• const string DefaultAppID = "Master"
• HostingOption HostType = HostingOption.NotSet
• string ServerAddress = DefaultServerAddress
• int ServerPort = 5055
• string AppID = ""
• List< string > RpcList
• bool DisableAutoOpenWizard

Static Public Attributes

• static readonly string[ ] CloudServerRegionPrefixes = new string[ ] {"app-eu", "app-us", "app-asia", "app-jp"}

13.22.1 Detailed Description

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
98 Class Documentation

13.22.2 Member Enumeration Documentation

13.22.2.1 enum ServerSettings.HostingOption

Enumerator

NotSet
PhotonCloud
SelfHosted
OfflineMode

13.22.3 Member Function Documentation

13.22.3.1 static int ServerSettings.FindRegionForServerAddress ( string server ) [static]

13.22.3.2 static string ServerSettings.FindServerAddressForRegion ( int regionIndex ) [static]

13.22.3.3 static string ServerSettings.FindServerAddressForRegion ( CloudServerRegion regionIndex ) [static]

13.22.3.4 override string ServerSettings.ToString ( )

13.22.3.5 void ServerSettings.UseCloud ( string cloudAppid, int regionIndex )

13.22.3.6 void ServerSettings.UseMyServer ( string serverAddress, int serverPort, string application )

13.22.4 Member Data Documentation

13.22.4.1 string ServerSettings.AppID = ""

13.22.4.2 readonly string [ ] ServerSettings.CloudServerRegionPrefixes = new string[ ] {"app-eu", "app-us", "app-asia", "app-jp"}
[static]

13.22.4.3 const string ServerSettings.DefaultAppID = "Master"

13.22.4.4 const string ServerSettings.DefaultCloudServerUrl = "app-eu.exitgamescloud.com"

13.22.4.5 const int ServerSettings.DefaultMasterPort = 5055

13.22.4.6 const string ServerSettings.DefaultServerAddress = "127.0.0.1"

13.22.4.7 bool ServerSettings.DisableAutoOpenWizard

13.22.4.8 HostingOption ServerSettings.HostType = HostingOption.NotSet

13.22.4.9 List<string> ServerSettings.RpcList

13.22.4.10 string ServerSettings.ServerAddress = DefaultServerAddress

13.22.4.11 int ServerSettings.ServerPort = 5055

The documentation for this class was generated from the following file:

• Photon Unity Networking/Plugins/PhotonNetwork/ServerSettings.cs

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
Chapter 14

File Documentation

14.1 _Doc/general.md File Reference

14.2 _Doc/main.md File Reference

14.3 _Doc/optionalGui.md File Reference

14.4 _Doc/photonStatsGui.md File Reference

14.5 _Doc/publicApi.md File Reference

14.6 Photon Unity Networking/Plugins/PhotonNetwork/CustomTypes.cs File Reference

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.

14.7 Photon Unity Networking/Plugins/PhotonNetwork/Enums.cs File Reference

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.

14.7.1 Enumeration Type Documentation

14.7.1.1 enum ConnectionState

High level connection state of the client. Better use the more detailed PeerState.

Enumerator

Disconnected
Connecting
Connected
Disconnecting
InitializingApplication

14.8 Photon Unity Networking/Plugins/PhotonNetwork/Extensions.cs File Reference

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

• using Hashtable = ExitGames.Client.Photon.Hashtable


• using SupportClass = ExitGames.Client.Photon.SupportClass

14.8.1 Typedef Documentation

14.8.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

14.8.1.2 using SupportClass = ExitGames.Client.Photon.SupportClass

14.9 Photon Unity Networking/Plugins/PhotonNetwork/FriendInfo.cs File Reference

Classes

• class FriendInfo
Used to store info about a friend’s online state and in which room he/she is.

14.10 Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs File Ref-


erence

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

• using Hashtable = ExitGames.Client.Photon.Hashtable

Enumerations

• enum MatchmakingMode : byte { MatchmakingMode.FillRoom = 0, MatchmakingMode.SerialMatching = 1,


MatchmakingMode.RandomMatching = 2 }
Options for matchmaking rules for OpJoinRandom.
• enum CustomAuthenticationType : byte { CustomAuthenticationType.Custom = 0, CustomAuthentication-
Type.Steam = 1, CustomAuthenticationType.Facebook = 2, CustomAuthenticationType.None = byte.Max-
Value }
Options for optional "Custom Authentication" services used with Photon. Used by OpAuthenticate after connecting to
Photon.

14.10.1 Typedef Documentation

14.10.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

14.10.2 Enumeration Type Documentation

14.10.2.1 enum CustomAuthenticationType : byte

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).

14.10.2.2 enum MatchmakingMode : byte

Options for matchmaking rules for OpJoinRandom.

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.

14.11 Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs File Refer-


ence

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

• using Hashtable = ExitGames.Client.Photon.Hashtable

14.11.1 Typedef Documentation

14.11.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

14.12 Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs File Refer-


ence

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.

14.13 Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs File Reference

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

• using Hashtable = ExitGames.Client.Photon.Hashtable

14.13.1 Typedef Documentation

14.13.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

14.14 Photon Unity Networking/Plugins/PhotonNetwork/PhotonLagSimulationGui.cs File


Reference

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.

14.15 Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs File Refer-


ence

Classes

• class PhotonNetwork
The main class to use the PhotonNetwork plugin. This class is static.

Typedefs

• using Hashtable = ExitGames.Client.Photon.Hashtable

14.15.1 Typedef Documentation

14.15.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

14.16 Photon Unity Networking/Plugins/PhotonNetwork/PhotonPlayer.cs File Reference

Classes

• class PhotonPlayer
Summarizes a "player" within a room, identified (in that room) by actorID.

Typedefs

• using Hashtable = ExitGames.Client.Photon.Hashtable

14.16.1 Typedef Documentation

14.16.1.1 using Hashtable = ExitGames.Client.Photon.Hashtable

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

14.17 Photon Unity Networking/Plugins/PhotonNetwork/PhotonStatsGui.cs File Refer-


ence

Classes

• class PhotonStatsGui
Basic GUI to show traffic and health statistics of the connection to Photon, toggled by shift+tab.

14.18 Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs File Reference

Classes

• class PhotonView
PUN’s NetworkView replacement class for networking. Use it like a NetworkView.

Enumerations

• enum ViewSynchronization { ViewSynchronization.Off, ViewSynchronization.ReliableDeltaCompressed,


ViewSynchronization.Unreliable, ViewSynchronization.UnreliableOnChange }
• enum OnSerializeTransform {
OnSerializeTransform.OnlyPosition, OnSerializeTransform.OnlyRotation, OnSerializeTransform.OnlyScale,
OnSerializeTransform.PositionAndRotation,
OnSerializeTransform.All }
• enum OnSerializeRigidBody { OnSerializeRigidBody.OnlyVelocity, OnSerializeRigidBody.OnlyAngular-
Velocity, OnSerializeRigidBody.All }

14.18.1 Enumeration Type Documentation

14.18.1.1 enum OnSerializeRigidBody

Enumerator

OnlyVelocity

OnlyAngularVelocity

All

14.18.1.2 enum OnSerializeTransform

Enumerator

OnlyPosition

OnlyRotation

OnlyScale

PositionAndRotation

All

Generated on Thu Oct 17 2013 18:24:41 for Photon Unity Networking by Doxygen
106 File Documentation

14.18.1.3 enum ViewSynchronization

Enumerator

Off
ReliableDeltaCompressed
Unreliable
UnreliableOnChange

14.19 Photon Unity Networking/Plugins/PhotonNetwork/PingCloudRegions.cs File Refer-


ence

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.

14.20 Photon Unity Networking/Plugins/PhotonNetwork/Room.cs File Reference

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.

14.21 Photon Unity Networking/Plugins/PhotonNetwork/RoomInfo.cs File Reference

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).

14.22 Photon Unity Networking/Plugins/PhotonNetwork/RPC.cs File Reference

14.23 Photon Unity Networking/Plugins/PhotonNetwork/RpcIndexComponent.cs File


Reference

14.24 Photon Unity Networking/Plugins/PhotonNetwork/ServerSettings.cs File Reference

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

• enum CloudServerRegion { CloudServerRegion.EU, CloudServerRegion.US, CloudServerRegion.Asia,


CloudServerRegion.Japan }
Currently available cloud regions as enum.

14.24.1 Enumeration Type Documentation

14.24.1.1 enum CloudServerRegion

Currently available cloud regions as enum.


Must match order in CloudServerRegionNames and CloudServerRegionPrefixes.

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

Connected, 100 SupportClass, 101


Connecting, 100
Disconnected, 100 Facebook
Disconnecting, 100 LoadbalancingPeer.cs, 102
InitializingApplication, 100 FetchServerTimestamp
Enums.cs PhotonNetwork, 69
ConnectionState, 100 FillRoom
Equals LoadbalancingPeer.cs, 102
PhotonPlayer, 82 Find
RoomInfo, 95 PhotonPlayer, 82
ErrorCode, 39 PhotonView, 88
AlreadyMatched, 40 FindFriends
CustomAuthenticationFailed, 40 OperationCode, 50
GameClosed, 40 PhotonNetwork, 69
GameDoesNotExist, 41 FindFriendsRequestList
GameFull, 41 ParameterCode, 54
GameIdAlreadyExists, 41 FindFriendsResponseOnlineList
InternalServerError, 41 ParameterCode, 54
InvalidAuthentication, 41 FindFriendsResponseRoomIdList
ParameterCode, 54
InvalidOperationCode, 41
FindRegionForServerAddress
InvalidRegion, 41
ServerSettings, 98
MaxCcuReached, 41
FindServerAddressForRegion
NoRandomMatchFound, 41
ServerSettings, 98
Ok, 42
FriendInfo, 46
OperationNotAllowedInCurrentState, 42
IsInRoom, 47
ServerFull, 42
IsOnline, 47
UserBlocked, 42
Name, 47
ErrorsOnly
Room, 47
Public API, 33
ToString, 47
EventCode, 42
Friends
AppStats, 43
PhotonNetwork, 78
AzureNodeInfo, 43
FriendsListAge
GameList, 43
PhotonNetwork, 79
GameListUpdate, 43
Full
Join, 43
Public API, 33
Leave, 43
Match, 43 GameClosed
PropertiesChanged, 43 ErrorCode, 40
QueueState, 43 GameCount
SetProperties, 44 ParameterCode, 54
Exception GameDoesNotExist
Public API, 32 ErrorCode, 41
ExceptionOnConnect GameFull
Public API, 31 ErrorCode, 41
ExecuteOnSerialize GameIdAlreadyExists
PhotonView, 88 ErrorCode, 41
Extensions, 44 GameList
AlmostEquals, 45 EventCode, 43
Contains, 45 ParameterCode, 54
GetPhotonView, 45 GameListUpdate
GetPhotonViewsInChildren, 45 EventCode, 43
Merge, 45 GameProperties, 47
MergeStringKeys, 45 CleanupCacheOnLeave, 48
StripKeysWithNullValues, 46 IsOpen, 48
StripToStringKeys, 46 IsVisible, 48
ToStringFull, 46 MaxPlayers, 48
Extensions.cs ParameterCode, 54
Hashtable, 101 PlayerCount, 48

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

Public API, 32 Name


FriendInfo, 47
Leave name
EventCode, 43 PhotonPlayer, 84
OperationCode, 50 Room, 93
LeaveLobby RoomInfo, 96
OperationCode, 51 nameField
LeaveRoom RoomInfo, 95
PhotonNetwork, 72 NetworkStatisticsEnabled
Leaving PhotonNetwork, 79
Public API, 32 NetworkStatisticsReset
LoadLevel PhotonNetwork, 73
PhotonNetwork, 72, 73 NetworkStatisticsToString
LoadbalancingPeer.cs PhotonNetwork, 73
Custom, 102 networkView
Facebook, 102 Photon::MonoBehaviour, 49
FillRoom, 102 NetworkingPeer.cs
None, 102 Hashtable, 103
RandomMatching, 102 NoRandomMatchFound
SerialMatching, 102 ErrorCode, 41
Steam, 102 None
LoadbalancingPeer.cs LoadbalancingPeer.cs, 102
CustomAuthenticationType, 102 NotSet
Hashtable, 102 ServerSettings, 98
MatchmakingMode, 102
logLevel observed
PhotonNetwork, 76 PhotonView, 89
Off
MAX_VIEW_IDS PhotonView.cs, 106
PhotonNetwork, 76 OfflineMode
MasterClient ServerSettings, 98
Public API, 34 offlineMode
masterClient PhotonNetwork, 79
PhotonNetwork, 79 Ok
MasterPeerCount ErrorCode, 42
ParameterCode, 55 OnConnectedToMaster
Match Public API, 34
EventCode, 43 OnConnectedToPhoton
MatchMakingType Public API, 33
ParameterCode, 55 OnConnectionFail
MatchmakingMode Public API, 33
LoadbalancingPeer.cs, 102 OnCreatedRoom
MaxCcuReached Public API, 33
Public API, 32 OnCustomAuthenticationFailed
MaxCcuReached Public API, 34
ErrorCode, 41 OnDisconnectedFromPhoton
maxConnections Public API, 33
PhotonNetwork, 79 OnFailedToConnectToPhoton
MaxPlayers Public API, 33
GameProperties, 48 OnJoinedLobby
maxPlayers Public API, 33
Room, 93 OnJoinedRoom
RoomInfo, 96 Public API, 33
maxPlayersField OnLeftLobby
RoomInfo, 95 Public API, 33
Merge OnLeftRoom
Extensions, 45 Public API, 33
MergeStringKeys OnMasterClientSwitched
Extensions, 45 Public API, 33

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

FindFriendsResponseOnlineList, 54 Room.cs, 106


FindFriendsResponseRoomIdList, 54 Photon Unity Networking/Plugins/PhotonNetwork/-
GameCount, 54 RoomInfo.cs, 106
GameList, 54 Photon Unity Networking/Plugins/PhotonNetwork/Rpc-
GameProperties, 54 IndexComponent.cs, 106
Group, 55 Photon Unity Networking/Plugins/PhotonNetwork/-
MasterPeerCount, 55 ServerSettings.cs, 106
MatchMakingType, 55 Photon.MonoBehaviour, 48
PeerCount, 55 PhotonCloud
PlayerProperties, 55 ServerSettings, 98
Position, 55 PhotonView.cs
Properties, 55 All, 105
ReceiverGroup, 55 Off, 106
Remove, 55 OnlyAngularVelocity, 105
RoomName, 55 OnlyPosition, 105
Secret, 55 OnlyRotation, 105
TargetActorNr, 56 OnlyScale, 105
UserId, 56 OnlyVelocity, 105
Peer PositionAndRotation, 105
PhotonLagSimulationGui, 58 ReliableDeltaCompressed, 106
PeerCreated Unreliable, 106
Public API, 32 UnreliableOnChange, 106
PeerCount Photon::MonoBehaviour
ParameterCode, 55 networkView, 49
PeerState photonView, 49
Public API, 32 PhotonHandler.cs
Photon, 35 Hashtable, 104
Photon Unity Networking/Plugins/PhotonNetwork/- PhotonLagSimulationGui, 57
CustomTypes.cs, 99 OnGUI, 58
Photon Unity Networking/Plugins/PhotonNetwork/- Peer, 58
Enums.cs, 99 Start, 58
Photon Unity Networking/Plugins/PhotonNetwork/- Visible, 58
Extensions.cs, 100 WindowId, 58
Photon Unity Networking/Plugins/PhotonNetwork/- WindowRect, 58
FriendInfo.cs, 101 PhotonLogLevel
Photon Unity Networking/Plugins/PhotonNetwork/- Public API, 32
LoadbalancingPeer.cs, 101 PhotonMessageInfo, 58
Photon Unity Networking/Plugins/PhotonNetwork/- PhotonMessageInfo, 59
NetworkingPeer.cs, 102 photonView, 59
Photon Unity Networking/Plugins/PhotonNetwork/- PhotonMessageInfo, 59
PhotonClasses.cs, 103 sender, 59
Photon Unity Networking/Plugins/PhotonNetwork/- timestamp, 59
PhotonHandler.cs, 103 ToString, 59
Photon Unity Networking/Plugins/PhotonNetwork/- PhotonNetwork, 59
PhotonLagSimulationGui.cs, 104 AllocateViewID, 64
Photon Unity Networking/Plugins/PhotonNetwork/- AuthValues, 77
PhotonNetwork.cs, 104 autoCleanUpPlayerObjects, 77
Photon Unity Networking/Plugins/PhotonNetwork/- autoJoinLobby, 78
PhotonPlayer.cs, 104 automaticallySyncScene, 78
Photon Unity Networking/Plugins/PhotonNetwork/- CloseConnection, 64
PhotonStatsGui.cs, 105 Connect, 64
Photon Unity Networking/Plugins/PhotonNetwork/- ConnectToBestCloudServer, 65
PhotonView.cs, 105 ConnectUsingSettings, 65
Photon Unity Networking/Plugins/PhotonNetwork/Ping- connected, 78
CloudRegions.cs, 106 connectionState, 78
Photon Unity Networking/Plugins/PhotonNetwork/RPC.- connectionStateDetailed, 78
cs, 106 countOfPlayers, 78
Photon Unity Networking/Plugins/PhotonNetwork/- countOfPlayersInRooms, 78

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

You might also like