Photon Unity Networking 2: IPunOwnershipCallbacks Interface Reference

Photon Unity Networking 2

IPunOwnershipCallbacks Interface Reference

This interface is used as definition of all callback methods of PUN, except OnPhotonSerializeView. Preferably, implement them individually. More...

Public Member Functions

void OnOwnershipRequest (PhotonView targetView, Player requestingPlayer)
 Called when another player requests ownership of a PhotonView from you (the current owner). More...
 
void OnOwnershipTransfered (PhotonView targetView, Player previousOwner)
 Called when ownership of a PhotonView is transfered to another player. More...
 

Detailed Description

This interface is used as definition of all callback methods of PUN, except OnPhotonSerializeView. Preferably, implement them individually.

This interface is available for completeness, more than for actually implementing it in a game. You can implement each method individually in any MonoMehaviour, without implementing IPunCallbacks.

PUN calls all callbacks by name. Don't use implement callbacks with fully qualified name. Example: IPunCallbacks.OnConnected won't get called by Unity's SendMessage().

PUN will call these methods on any script that implements them, analog to Unity's events and callbacks. The situation that triggers the call is described per method.

OnPhotonSerializeView is NOT called like these callbacks! It's usage frequency is much higher and it is implemented in: IPunObservable.

Member Function Documentation

void OnOwnershipRequest ( PhotonView  targetView,
Player  requestingPlayer 
)

Called when another player requests ownership of a PhotonView from you (the current owner).

The parameter viewAndPlayer contains:

PhotonView view = viewAndPlayer[0] as PhotonView;

Player requestingPlayer = viewAndPlayer[1] as Player;

Parameters
targetViewPhotonView for which ownership gets requested.
requestingPlayerPlayer who requests ownership.
void OnOwnershipTransfered ( PhotonView  targetView,
Player  previousOwner 
)

Called when ownership of a PhotonView is transfered to another player.

The parameter viewAndPlayers contains:

PhotonView view = viewAndPlayers[0] as PhotonView;

Player newOwner = viewAndPlayers[1] as Player;

Player oldOwner = viewAndPlayers[2] as Player;

void OnOwnershipTransfered(object[] viewAndPlayers) {} //

Parameters
targetViewPhotonView for which ownership changed.
previousOwnerPlayer who was the previous owner (or null, if none).
Online Documentation  -  Dashboard  -  Support Forum Exit Games GmbH