Photon Unity Networking 2 2.45

Public Member Functions | List of all members
IPunOwnershipCallbacks Interface Reference

Global Callback interface for ownership changes. These callbacks will fire for changes to ANY PhotonView that changes. Consider using IOnPhotonViewControllerChange for callbacks from a specific PhotonView. More...

Public Member Functions

void OnOwnershipRequest (PhotonView targetView, Player requestingPlayer)
 Called when another player requests ownership of a PhotonView. Called on all clients, so check if (targetView.IsMine) or (targetView.Owner == PhotonNetwork.LocalPlayer) to determine if a targetView.TransferOwnership(requestingPlayer) response should be given. More...
 
void OnOwnershipTransfered (PhotonView targetView, Player previousOwner)
 Called when ownership of a PhotonView is transfered to another player. More...
 
void OnOwnershipTransferFailed (PhotonView targetView, Player senderOfFailedRequest)
 Called when an Ownership Request fails for objects with "takeover" setting. More...
 

Detailed Description

Global Callback interface for ownership changes. These callbacks will fire for changes to ANY PhotonView that changes. Consider using IOnPhotonViewControllerChange for callbacks from a specific PhotonView.

Member Function Documentation

◆ OnOwnershipRequest()

void OnOwnershipRequest ( PhotonView  targetView,
Player  requestingPlayer 
)

Called when another player requests ownership of a PhotonView. Called on all clients, so check if (targetView.IsMine) or (targetView.Owner == PhotonNetwork.LocalPlayer) to determine if a targetView.TransferOwnership(requestingPlayer) response should be given.

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.

◆ OnOwnershipTransfered()

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

◆ OnOwnershipTransferFailed()

void OnOwnershipTransferFailed ( PhotonView  targetView,
Player  senderOfFailedRequest 
)

Called when an Ownership Request fails for objects with "takeover" setting.

Each request asks to take ownership from a specific controlling player. This can fail if anyone else took over ownership briefly before the request arrived.

Parameters
targetView
senderOfFailedRequest