Photon Unity Networking 2: IInRoomCallbacks Interface Reference

Photon Unity Networking 2

IInRoomCallbacks Interface Reference

Collection of "in room" callbacks for the Realtime Api to cover: Players entering or leaving, property updates and Master Client switching. More...

Inherited by MonoBehaviourPunCallbacks, PhotonHandler, InRoomCallbacksContainer, and SupportLogger.

Public Member Functions

void OnPlayerEnteredRoom (Player newPlayer)
 Called when a remote player entered the room. This Player is already added to the playerlist. More...
 
void OnPlayerLeftRoom (Player otherPlayer)
 Called when a remote player left the room or became inactive. Check otherPlayer.IsInactive. More...
 
void OnRoomPropertiesUpdate (Hashtable propertiesThatChanged)
 Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties. More...
 
void OnPlayerPropertiesUpdate (Player targetPlayer, Hashtable changedProps)
 Called when custom player-properties are changed. Player and the changed properties are passed as object[]. More...
 
void OnMasterClientSwitched (Player newMasterClient)
 Called after switching to a new MasterClient when the current one leaves. More...
 

Detailed Description

Collection of "in room" callbacks for the Realtime Api to cover: Players entering or leaving, property updates and Master Client switching.

The callback to get events is in a separate interface: IOnEventCallback.

To register for callbacks, PhotonNetwork.AddCallbackTarget(<Your Component implementing this interface>); To stop getting callbacks, PhotonNetwork.RemoveCallbackTarget(<Your Component implementing this interface>);

You can also simply override MonoBehaviourPunCallbacks which will provide you with Magic Callbacks ( like Unity would call Start(), Update() on a MonoBehaviour)

Member Function Documentation

void OnMasterClientSwitched ( Player  newMasterClient)

Called after switching to a new MasterClient when the current one leaves.

This is not called when this client enters a room. The former MasterClient is still in the player list when this method get called.

Implemented in MonoBehaviourPunCallbacks, and SupportLogger.

void OnPlayerEnteredRoom ( Player  newPlayer)

Called when a remote player entered the room. This Player is already added to the playerlist.

If your game starts with a certain number of players, this callback can be useful to check the Room.playerCount and find out if you can start.

Implemented in MonoBehaviourPunCallbacks, SupportLogger, PlayerNumbering, and PunTeams.

void OnPlayerLeftRoom ( Player  otherPlayer)

Called when a remote player left the room or became inactive. Check otherPlayer.IsInactive.

If another player leaves the room or if the server detects a lost connection, this callback will be used to notify your game logic.

Depending on the room's setup, players may become inactive, which means they may return and retake their spot in the room. In such cases, the Player stays in the Room.Players dictionary.

If the player is not just inactive, it gets removed from the Room.Players dictionary, before the callback is called.

Implemented in MonoBehaviourPunCallbacks, SupportLogger, PlayerNumbering, and PunTeams.

void OnPlayerPropertiesUpdate ( Player  targetPlayer,
Hashtable  changedProps 
)

Called when custom player-properties are changed. Player and the changed properties are passed as object[].

Changing properties must be done by Player.SetCustomProperties, which causes this callback locally, too.

Parameters
targetPlayerContains Player that changed.
changedPropsContains the properties that changed.

Implemented in MonoBehaviourPunCallbacks, SupportLogger, PlayerNumbering, and PunTeams.

void OnRoomPropertiesUpdate ( Hashtable  propertiesThatChanged)

Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties.

Since v1.25 this method has one parameter: Hashtable propertiesThatChanged.
Changing properties must be done by Room.SetCustomProperties, which causes this callback locally, too.

Parameters
propertiesThatChanged

Implemented in MonoBehaviourPunCallbacks, PunTurnManager, SupportLogger, and CountdownTimer.

Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH