C# Class PhotonNetwork, PaperCowboys

The main class to use the PhotonNetwork plugin. This class is static.
Datei anzeigen Open project: Gamieon/PaperCowboys Class Usage Examples

Public Properties

Property Type Description
MAX_VIEW_IDS int
PrefabCache GameObject>.Dictionary
UsePrefabCache bool
logLevel PhotonLogLevel
precisionForFloatSynchronization float
precisionForQuaternionSynchronization float
precisionForVectorSynchronization float

Private Properties

Property Type Description
AllocateSceneViewIDs int[]
AllocateViewID int
Connect void
ConnectUsingSettings void
InitializeSecurity void
PhotonNetwork System
RPC void
RPC void
VerifyCanUseNetwork bool

Public Methods

Method Description
AllocateViewID ( ) : int

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

CloseConnection ( PhotonPlayer, kickPlayer ) : void

Request a client to disconnect (KICK). Only the master client can do this.

Connect ( string serverAddress, int port, string appID, string gameVersion ) : void

Connect to the photon server by address, port, appID and game(client) version. This method is used by ConnectUsingSettings which applies values from the settings file.

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/

ConnectUsingSettings ( string gameVersion ) : void

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

CreateRoom ( string roomName ) : void

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.

CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers ) : void

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

CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable customRoomProperties, string propsToListInLobby ) : void

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.

Destroy ( GameObject go ) : void

Destroys given GameObject. This GameObject must've been instantiated using PhotonNetwork.Instantiate and must have a PhotonView at it's root. This has the same effect as calling Destroy by passing an attached PhotonView from this GameObject

Destroy ( PhotonView view ) : void

Destroy supplied PhotonView. This will remove all Buffered RPCs and destroy the GameObject this view is attached to (plus all childs, if any) This has the same effect as calling Destroy by passing a GameObject

DestroyPlayerObjects ( PhotonPlayer destroyPlayer ) : void

Destroy all GameObjects/PhotonViews of this player. can only be called on the local player. The only exception is the master client which call call this for all players.

Disconnect ( ) : void

Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFromPhoton on completition.

When the client is connected, the server is being informed that this client disconnects. 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.

GetPing ( ) : int

The current roundtrip time to the photon server

GetRoomList ( ) : RoomInfo[]

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.

Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject

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.

Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group, object data ) : GameObject

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.

InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group, object data ) : GameObject

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.

InternalCleanPhotonMonoFromSceneIfStuck ( ) : void

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

JoinRandomRoom ( ) : void

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). Alternatively, try again in a moment.

JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers ) : void

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). Alternatively, try again in a moment.

JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType ) : void

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). Alternatively, try again in a moment.

JoinRoom ( RoomInfo listedRoom ) : void

Join room by room.Name. This fails if the room is either full or no longer available (might close at the same time).

JoinRoom ( string roomName ) : void

Join room with given title. This fails if the room is either full or no longer available (might close at the same time).

LeaveRoom ( ) : void

Leave the current room

LoadLevel ( int levelNumber ) : void

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.

LoadLevel ( string levelTitle ) : void

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.

NetworkStatisticsReset ( ) : void

Resets the traffic stats and re-enables them.

NetworkStatisticsToString ( ) : string

Only available when NetworkStatisticsEnabled was used to gather some stats.

RemoveAllBufferedMessages ( ) : void

Remove ALL buffered messages of the local player (RPC's and Instantiation calls) Note that this only removed the buffered messages on the server, you will still need to remove the Instantiated GameObjects yourself.

RemoveAllBufferedMessages ( PhotonPlayer targetPlayer ) : void

Remove ALL buffered messages of a player (RPC's and Instantiation calls) Note that this only removed the buffered messages on the server, you will still need to remove the Instantiated GameObjects yourself.

RemoveAllInstantiatedObjects ( ) : void

MasterClient method only: Destroy ALL instantiated GameObjects

RemoveAllInstantiatedObjects ( PhotonPlayer targetPlayer ) : void

Destroy ALL PhotonNetwork.Instantiated GameObjects by given player. Can only be called on the local player or MasterClient. The MasterClient can call this for all players.

RemoveRPCs ( ) : void

Remove ALL buffered RPCs of the local player

RemoveRPCs ( PhotonPlayer targetPlayer ) : void

Remove ALL buffered RPCs of a player

RemoveRPCs ( PhotonView view ) : void

Remove all buffered RPCs on given PhotonView (if they are owned by this player).

RemoveRPCsInGroup ( int group ) : void

Remove all buffered RPCs with given group

SendOutgoingCommands ( ) : void

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.

SetLevelPrefix ( short prefix ) : void

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.

SetPlayerCustomProperties ( Hashtable customProperties ) : void

Sets this (local) player's properties. This caches the properties in PhotonNetwork.player.customProperties. CreateRoom, 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!

SetReceivingEnabled ( int group, bool enabled ) : void

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

SetSendingEnabled ( int group, bool enabled ) : void

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

UnAllocateViewID ( int viewID ) : void

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

Private Methods

Method Description
AllocateSceneViewIDs ( int countOfNewViews ) : int[]
AllocateViewID ( int ownerId ) : int
Connect ( string serverAddress, int port, string uniqueGameID ) : void
ConnectUsingSettings ( ) : void
InitializeSecurity ( ) : void
PhotonNetwork ( ) : System

Static constructor used for basic setup.

RPC ( PhotonView view, string methodName, PhotonPlayer targetPlayer ) : void

Internal to send an RPC on given PhotonView. Do not call this directly but use: PhotonView.RPC!

RPC ( PhotonView view, string methodName, PhotonTargets target ) : void

Internal to send an RPC on given PhotonView. Do not call this directly but use: PhotonView.RPC!

VerifyCanUseNetwork ( ) : bool

Helper function which is called inside this class to erify if certain functions can be used (e.g. RPC when not connected)

Method Details

AllocateViewID() public static method

Allocates a viewID that's valid for the current/local player.
public static AllocateViewID ( ) : int
return int

CloseConnection() public static method

Request a client to disconnect (KICK). Only the master client can do this.
public static CloseConnection ( PhotonPlayer, kickPlayer ) : void
kickPlayer PhotonPlayer, The PhotonPlayer to kick.
return void

Connect() public static method

Connect to the photon server by address, port, appID and game(client) version. This method is used by ConnectUsingSettings which applies values from the settings file.
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/
public static Connect ( string serverAddress, int port, string appID, string gameVersion ) : void
serverAddress string The master server's address (either your own or Photon Cloud address).
port int The master server's port to connect to.
appID string Your application ID (Photon Cloud provides you with a GUID for your game).
gameVersion string This client's version number. Users are separated from each other by gameversion (which allows you to make breaking changes).
return void

ConnectUsingSettings() public static method

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
public static ConnectUsingSettings ( string gameVersion ) : void
gameVersion string This client's version number. Users are separated from each other by gameversion (which allows you to make breaking changes).
return void

CreateRoom() public static method

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.
public static CreateRoom ( string roomName ) : void
roomName string Unique name of the room to create.
return void

CreateRoom() public static method

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
public static CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers ) : void
roomName string Unique name of the room to create. Pass null or "" to make the server generate a name.
isVisible bool Shows (or hides) this room from the lobby's listing of rooms.
isOpen bool Allows (or disallows) others to join this room.
maxPlayers int Max number of players that can join the room.
return void

CreateRoom() public static method

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.
public static CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable customRoomProperties, string propsToListInLobby ) : void
roomName string Unique name of the room to create. Pass null or "" to make the server generate a name.
isVisible bool Shows (or hides) this room from the lobby's listing of rooms.
isOpen bool Allows (or disallows) others to join this room.
maxPlayers int Max number of players that can join the room.
customRoomProperties Hashtable Custom properties of the new room (set on create, so they are immediately available).
propsToListInLobby string Array of custom-property-names that should be forwarded to the lobby (include only the useful ones).
return void

Destroy() public static method

Destroys given GameObject. This GameObject must've been instantiated using PhotonNetwork.Instantiate and must have a PhotonView at it's root. This has the same effect as calling Destroy by passing an attached PhotonView from this GameObject
public static Destroy ( GameObject go ) : void
go GameObject
return void

Destroy() public static method

Destroy supplied PhotonView. This will remove all Buffered RPCs and destroy the GameObject this view is attached to (plus all childs, if any) This has the same effect as calling Destroy by passing a GameObject
public static Destroy ( PhotonView view ) : void
view PhotonView
return void

DestroyPlayerObjects() public static method

Destroy all GameObjects/PhotonViews of this player. can only be called on the local player. The only exception is the master client which call call this for all players.
public static DestroyPlayerObjects ( PhotonPlayer destroyPlayer ) : void
destroyPlayer PhotonPlayer
return void

Disconnect() public static method

Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFromPhoton on completition.
When the client is connected, the server is being informed that this client disconnects. 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.
public static Disconnect ( ) : void
return void

GetPing() public static method

The current roundtrip time to the photon server
public static GetPing ( ) : int
return int

GetRoomList() public static method

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.
public static GetRoomList ( ) : RoomInfo[]
return RoomInfo[]

Instantiate() public static method

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.
public static Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this PhotonView.
return GameObject

Instantiate() public static method

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.
public static Instantiate ( string prefabName, Vector3 position, Quaternion rotation, int group, object data ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this PhotonView.
data object Optional instantiation data. This will be saved to it's PhotonView.instantiationData.
return GameObject

InstantiateSceneObject() public static method

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.
public static InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group, object data ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this PhotonView.
data object Optional instantiation data. This will be saved to it's PhotonView.instantiationData.
return GameObject

InternalCleanPhotonMonoFromSceneIfStuck() public static method

Internally used by Editor scripts, called on Hierarchy change (includes scene save) to remove surplus hidden PhotonHandlers.
public static InternalCleanPhotonMonoFromSceneIfStuck ( ) : void
return void

JoinRandomRoom() public static method

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). Alternatively, try again in a moment.
public static JoinRandomRoom ( ) : void
return void

JoinRandomRoom() public static method

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). Alternatively, try again in a moment.
public static JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers ) : void
expectedCustomRoomProperties Hashtable Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.
expectedMaxPlayers byte Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.
return void

JoinRandomRoom() public static method

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). Alternatively, try again in a moment.
public static JoinRandomRoom ( Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType ) : void
expectedCustomRoomProperties Hashtable Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.
expectedMaxPlayers byte Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.
matchingType MatchmakingMode Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.
return void

JoinRoom() public static method

Join room by room.Name. This fails if the room is either full or no longer available (might close at the same time).
public static JoinRoom ( RoomInfo listedRoom ) : void
listedRoom RoomInfo
return void

JoinRoom() public static method

Join room with given title. This fails if the room is either full or no longer available (might close at the same time).
public static JoinRoom ( string roomName ) : void
roomName string Unique name of the room to create.
return void

LeaveRoom() public static method

Leave the current room
public static LeaveRoom ( ) : void
return void

LoadLevel() public static method

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.
public static LoadLevel ( int levelNumber ) : void
levelNumber int /// Number of the level to load (make sure it's in the build preferences). ///
return void

LoadLevel() public static method

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.
public static LoadLevel ( string levelTitle ) : void
levelTitle string /// Name of the level to load. ///
return void

NetworkStatisticsReset() public static method

Resets the traffic stats and re-enables them.
public static NetworkStatisticsReset ( ) : void
return void

NetworkStatisticsToString() public static method

Only available when NetworkStatisticsEnabled was used to gather some stats.
public static NetworkStatisticsToString ( ) : string
return string

RemoveAllBufferedMessages() public static method

Remove ALL buffered messages of the local player (RPC's and Instantiation calls) Note that this only removed the buffered messages on the server, you will still need to remove the Instantiated GameObjects yourself.
public static RemoveAllBufferedMessages ( ) : void
return void

RemoveAllBufferedMessages() public static method

Remove ALL buffered messages of a player (RPC's and Instantiation calls) Note that this only removed the buffered messages on the server, you will still need to remove the Instantiated GameObjects yourself.
public static RemoveAllBufferedMessages ( PhotonPlayer targetPlayer ) : void
targetPlayer PhotonPlayer
return void

RemoveAllInstantiatedObjects() public static method

MasterClient method only: Destroy ALL instantiated GameObjects
public static RemoveAllInstantiatedObjects ( ) : void
return void

RemoveAllInstantiatedObjects() public static method

Destroy ALL PhotonNetwork.Instantiated GameObjects by given player. Can only be called on the local player or MasterClient. The MasterClient can call this for all players.
public static RemoveAllInstantiatedObjects ( PhotonPlayer targetPlayer ) : void
targetPlayer PhotonPlayer
return void

RemoveRPCs() public static method

Remove ALL buffered RPCs of the local player
public static RemoveRPCs ( ) : void
return void

RemoveRPCs() public static method

Remove ALL buffered RPCs of a player
public static RemoveRPCs ( PhotonPlayer targetPlayer ) : void
targetPlayer PhotonPlayer
return void

RemoveRPCs() public static method

Remove all buffered RPCs on given PhotonView (if they are owned by this player).
public static RemoveRPCs ( PhotonView view ) : void
view PhotonView
return void

RemoveRPCsInGroup() public static method

Remove all buffered RPCs with given group
public static RemoveRPCsInGroup ( int group ) : void
group int
return void

SendOutgoingCommands() public static method

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.
public static SendOutgoingCommands ( ) : void
return void

SetLevelPrefix() public static method

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.
public static SetLevelPrefix ( short prefix ) : void
prefix short Max value is short.MaxValue = 32767
return void

SetPlayerCustomProperties() public static method

Sets this (local) player's properties. This caches the properties in PhotonNetwork.player.customProperties. CreateRoom, 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!
public static SetPlayerCustomProperties ( Hashtable customProperties ) : void
customProperties Hashtable Only string-typed keys will be used from this hashtable. If null, custom properties are all deleted.
return void

SetReceivingEnabled() public static method

Enable/disable receiving on given group (applied to PhotonViews)
public static SetReceivingEnabled ( int group, bool enabled ) : void
group int
enabled bool
return void

SetSendingEnabled() public static method

Enable/disable sending on given group (applied to PhotonViews)
public static SetSendingEnabled ( int group, bool enabled ) : void
group int
enabled bool
return void

UnAllocateViewID() public static method

Unregister a viewID (of manually instantiated and destroyed networked objects).
public static UnAllocateViewID ( int viewID ) : void
viewID int A viewID manually allocated by this player.
return void

Property Details

MAX_VIEW_IDS public_oe static_oe property

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

PrefabCache public_oe static_oe property

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.
public static Dictionary PrefabCache
return GameObject>.Dictionary

UsePrefabCache public_oe static_oe property

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.
public static bool UsePrefabCache
return bool

logLevel public_oe static_oe property

Network log level. Controls how verbose PUN is.
public static PhotonLogLevel logLevel
return PhotonLogLevel

precisionForFloatSynchronization public_oe static_oe property

The minimum difference between floats before we send it via a PhotonView's OnSerialize/ObservingComponent
public static float precisionForFloatSynchronization
return float

precisionForQuaternionSynchronization public_oe static_oe property

The minimum angle that a rotation needs to change before we send it via a PhotonView's OnSerialize/ObservingComponent
public static float precisionForQuaternionSynchronization
return float

precisionForVectorSynchronization public_oe static_oe property

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.
public static float precisionForVectorSynchronization
return float