A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances. More...

Inheritance diagram for Photon.Pun.PhotonView:

Public Types

enum  ObservableSearch { ObservableSearch.Manual, ObservableSearch.AutoFindActive, ObservableSearch.AutoFindAll }
 

Public Member Functions

void OnPreNetDestroy (PhotonView rootView)
 
void RequestOwnership ()
 Depending on the PhotonView's OwnershipTransfer setting, any client can request to become owner of the PhotonView. More...
 
void TransferOwnership (Player newOwner)
 Transfers the ownership of this PhotonView (and GameObject) to another player. More...
 
void TransferOwnership (int newOwnerId)
 Transfers the ownership of this PhotonView (and GameObject) to another player. More...
 
void FindObservables (bool force=false)
 Will find IPunObservable components on this GameObject and nested children and add them to the ObservedComponents list. More...
 
void SerializeView (PhotonStream stream, PhotonMessageInfo info)
 
void DeserializeView (PhotonStream stream, PhotonMessageInfo info)
 
void RefreshRpcMonoBehaviourCache ()
 Can be used to refesh the list of MonoBehaviours on this GameObject while PhotonNetwork.UseRpcMonoBehaviourCache is true. More...
 
void RPC (string methodName, RpcTarget target, params object[] parameters)
 Call a RPC method of this GameObject on remote clients of this room (or on all, including this client). More...
 
void RpcSecure (string methodName, RpcTarget target, bool encrypt, params object[] parameters)
 Call a RPC method of this GameObject on remote clients of this room (or on all, including this client). More...
 
void RPC (string methodName, Player targetPlayer, params object[] parameters)
 Call a RPC method of this GameObject on remote clients of this room (or on all, including this client). More...
 
void RpcSecure (string methodName, Player targetPlayer, bool encrypt, params object[] parameters)
 Call a RPC method of this GameObject on remote clients of this room (or on all, including this client). More...
 
void AddCallbackTarget (IPhotonViewCallback obj)
 Add object to all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface. More...
 
void RemoveCallbackTarget (IPhotonViewCallback obj)
 Remove object from all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface. More...
 
void AddCallback< T > (IPhotonViewCallback obj)
 Add object to this PhotonView's callback. T is the IOnPhotonViewCallback derived interface you want added to its associated callback list. Supplying IOnPhotonViewCallback (the interface base class) as T will add ALL implemented IOnPhotonViewCallback Interfaces found on the object. More...
 
void RemoveCallback< T > (IPhotonViewCallback obj)
 Remove object from this PhotonView's callback list for T. T is the IOnPhotonViewCallback derived interface you want removed from its associated callback list. Supplying IOnPhotonViewCallback (the interface base class) as T will remove ALL implemented IOnPhotonViewCallback Interfaces found on the object. More...
 
override string ToString ()
 

Static Public Member Functions

static PhotonView Get (Component component)
 
static PhotonView Get (GameObject gameObj)
 
static PhotonView Find (int viewID)
 Finds the PhotonView Component with a viewID in the scene More...
 

Public Attributes

byte Group = 0
 
int prefixField = -1
 
ViewSynchronization Synchronization = ViewSynchronization.UnreliableOnChange
 
OwnershipOption OwnershipTransfer = OwnershipOption.Fixed
 Defines if ownership of this PhotonView is fixed, can be requested or simply taken. More...
 
ObservableSearch observableSearch = ObservableSearch.Manual
 Default to manual so existing PVs in projects default to same as before. Reset() changes this to AutoAll for new implementations. More...
 
List< Component > ObservedComponents
 
int sceneViewId = 0
 This field is the Scene ViewID (0 if not used). loaded with the scene, used in Awake(). More...
 
int InstantiationId
 
bool isRuntimeInstantiated
 

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) More...
 
bool IsSceneView [get]
 
bool IsRoomView [get]
 True if the PhotonView was loaded with the scene (game object) or instantiated with InstantiateRoomObject. More...
 
bool IsOwnerActive [get]
 
bool IsMine [get]
 True if the PhotonView is "mine" and can be controlled by this client. More...
 
bool AmController [get]
 
Player Controller [get]
 
int CreatorActorNr [get]
 
bool AmOwner [get]
 
Player Owner [get]
 The owner of a PhotonView is the creator of an object by default Ownership can be transferred and the owner may not be in the room anymore. Objects in the scene don't have an owner. More...
 
int OwnerActorNr [get, set]
 
int ControllerActorNr [get, set]
 
int ViewID [get, set]
 The ID of the PhotonView. Identifies it in a networked game (per room). More...
 

Detailed Description

A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances.

Member Enumeration Documentation

◆ ObservableSearch

Enumerator
Manual 
AutoFindActive 
AutoFindAll 

Member Function Documentation

◆ AddCallback< T >()

void Photon.Pun.PhotonView.AddCallback< T > ( IPhotonViewCallback  obj)

Add object to this PhotonView's callback. T is the IOnPhotonViewCallback derived interface you want added to its associated callback list. Supplying IOnPhotonViewCallback (the interface base class) as T will add ALL implemented IOnPhotonViewCallback Interfaces found on the object.

Type Constraints
T :class 
T :IPhotonViewCallback 

◆ AddCallbackTarget()

void Photon.Pun.PhotonView.AddCallbackTarget ( IPhotonViewCallback  obj)

Add object to all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface.

Parameters
objAn object that implements OnPhotonView callback interface(s).

◆ DeserializeView()

void Photon.Pun.PhotonView.DeserializeView ( PhotonStream  stream,
PhotonMessageInfo  info 
)

◆ Find()

static PhotonView Photon.Pun.PhotonView.Find ( int  viewID)
static

Finds the PhotonView Component with a viewID in the scene

Parameters
viewID
Returns
The PhotonView with ViewID. Returns null if none found

◆ FindObservables()

void Photon.Pun.PhotonView.FindObservables ( bool  force = false)

Will find IPunObservable components on this GameObject and nested children and add them to the ObservedComponents list.

This is called via PhotonView.Awake(), which in turn is called immediately by the engine's AddComponent method.

Changing the ObservedComponents of a PhotonView at runtime can be problematic, if other clients are not also updating their list.

Parameters
forceIf true, FindObservables will work as if observableSearch is AutoFindActive.

◆ Get() [1/2]

static PhotonView Photon.Pun.PhotonView.Get ( Component  component)
static

◆ Get() [2/2]

static PhotonView Photon.Pun.PhotonView.Get ( GameObject  gameObj)
static

◆ OnPreNetDestroy()

void Photon.Pun.PhotonView.OnPreNetDestroy ( PhotonView  rootView)

◆ RefreshRpcMonoBehaviourCache()

void Photon.Pun.PhotonView.RefreshRpcMonoBehaviourCache ( )

Can be used to refesh the list of MonoBehaviours on this GameObject while PhotonNetwork.UseRpcMonoBehaviourCache is true.

Set PhotonNetwork.UseRpcMonoBehaviourCache to true to enable the caching. Uses this.GetComponents<MonoBehaviour>() to get a list of MonoBehaviours to call RPCs on (potentially).

While PhotonNetwork.UseRpcMonoBehaviourCache is false, this method has no effect, because the list is refreshed when a RPC gets called.

◆ RemoveCallback< T >()

void Photon.Pun.PhotonView.RemoveCallback< T > ( IPhotonViewCallback  obj)

Remove object from this PhotonView's callback list for T. T is the IOnPhotonViewCallback derived interface you want removed from its associated callback list. Supplying IOnPhotonViewCallback (the interface base class) as T will remove ALL implemented IOnPhotonViewCallback Interfaces found on the object.

Type Constraints
T :class 
T :IPhotonViewCallback 

◆ RemoveCallbackTarget()

void Photon.Pun.PhotonView.RemoveCallbackTarget ( IPhotonViewCallback  obj)

Remove object from all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface.

Parameters
objAn object that implements OnPhotonView callback interface(s).

◆ RequestOwnership()

void Photon.Pun.PhotonView.RequestOwnership ( )

Depending on the PhotonView's OwnershipTransfer setting, any client can request to become owner of the PhotonView.

Requesting ownership can give you control over a PhotonView, if the OwnershipTransfer setting allows that. The current owner might have to implement IPunCallbacks.OnOwnershipRequest to react to the ownership request.

The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.

◆ RPC() [1/2]

void Photon.Pun.PhotonView.RPC ( string  methodName,
RpcTarget  target,
params object []  parameters 
)

Call a RPC method of this GameObject on remote clients of this room (or on all, including this client).

Remote Procedure Calls are an essential tool in making multiplayer games with PUN. It enables you to make every client in a room call a specific method.

RPC calls can target "All" or the "Others". Usually, the target "All" gets executed locally immediately after sending the RPC. The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. Of course, calls are affected by this client's lag and that of remote clients.

Each call automatically is routed to the same PhotonView (and GameObject) that was used on the originating client.

See: Remote Procedure Calls.

Parameters
methodNameThe name of a fitting method that was has the RPC attribute.
targetThe group of targets and the way the RPC gets sent.
parametersThe parameters that the RPC method has (must fit this call!).

◆ RPC() [2/2]

void Photon.Pun.PhotonView.RPC ( string  methodName,
Player  targetPlayer,
params object []  parameters 
)

Call a RPC method of this GameObject on remote clients of this room (or on all, including this client).

Remote Procedure Calls are an essential tool in making multiplayer games with PUN. It enables you to make every client in a room call a specific method.

This method allows you to make an RPC calls on a specific player's client. Of course, calls are affected by this client's lag and that of remote clients.

Each call automatically is routed to the same PhotonView (and GameObject) that was used on the originating client.

See: Remote Procedure Calls.

Parameters
methodNameThe name of a fitting method that was has the RPC attribute.
targetPlayerThe group of targets and the way the RPC gets sent.
parametersThe parameters that the RPC method has (must fit this call!).

◆ RpcSecure() [1/2]

void Photon.Pun.PhotonView.RpcSecure ( string  methodName,
RpcTarget  target,
bool  encrypt,
params object []  parameters 
)

Call a RPC method of this GameObject on remote clients of this room (or on all, including this client).

Remote Procedure Calls are an essential tool in making multiplayer games with PUN. It enables you to make every client in a room call a specific method.

RPC calls can target "All" or the "Others". Usually, the target "All" gets executed locally immediately after sending the RPC. The "*ViaServer" options send the RPC to the server and execute it on this client when it's sent back. Of course, calls are affected by this client's lag and that of remote clients.

Each call automatically is routed to the same PhotonView (and GameObject) that was used on the originating client.

See: Remote Procedure Calls.

param name="methodName">The name of a fitting method that was has the RPC attribute.

param name="target">The group of targets and the way the RPC gets sent.

param name="encrypt">

param name="parameters">The parameters that the RPC method has (must fit this call!).

◆ RpcSecure() [2/2]

void Photon.Pun.PhotonView.RpcSecure ( string  methodName,
Player  targetPlayer,
bool  encrypt,
params object []  parameters 
)

Call a RPC method of this GameObject on remote clients of this room (or on all, including this client).

Remote Procedure Calls are an essential tool in making multiplayer games with PUN. It enables you to make every client in a room call a specific method.

This method allows you to make an RPC calls on a specific player's client. Of course, calls are affected by this client's lag and that of remote clients.

Each call automatically is routed to the same PhotonView (and GameObject) that was used on the originating client.

See: Remote Procedure Calls.

param name="methodName">The name of a fitting method that was has the RPC attribute.

param name="targetPlayer">The group of targets and the way the RPC gets sent.

param name="encrypt">

param name="parameters">The parameters that the RPC method has (must fit this call!).

◆ SerializeView()

void Photon.Pun.PhotonView.SerializeView ( PhotonStream  stream,
PhotonMessageInfo  info 
)

◆ ToString()

override string Photon.Pun.PhotonView.ToString ( )

◆ TransferOwnership() [1/2]

void Photon.Pun.PhotonView.TransferOwnership ( Player  newOwner)

Transfers the ownership of this PhotonView (and GameObject) to another player.

The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.

◆ TransferOwnership() [2/2]

void Photon.Pun.PhotonView.TransferOwnership ( int  newOwnerId)

Transfers the ownership of this PhotonView (and GameObject) to another player.

The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.

Member Data Documentation

◆ Group

byte Photon.Pun.PhotonView.Group = 0

◆ InstantiationId

int Photon.Pun.PhotonView.InstantiationId

◆ isRuntimeInstantiated

bool Photon.Pun.PhotonView.isRuntimeInstantiated

◆ observableSearch

ObservableSearch Photon.Pun.PhotonView.observableSearch = ObservableSearch.Manual

Default to manual so existing PVs in projects default to same as before. Reset() changes this to AutoAll for new implementations.

◆ ObservedComponents

List<Component> Photon.Pun.PhotonView.ObservedComponents

◆ OwnershipTransfer

OwnershipOption Photon.Pun.PhotonView.OwnershipTransfer = OwnershipOption.Fixed

Defines if ownership of this PhotonView is fixed, can be requested or simply taken.

Note that you can't edit this value at runtime. The options are described in enum OwnershipOption. The current owner has to implement IPunCallbacks.OnOwnershipRequest to react to the ownership request.

◆ prefixField

int Photon.Pun.PhotonView.prefixField = -1

◆ sceneViewId

int Photon.Pun.PhotonView.sceneViewId = 0

This field is the Scene ViewID (0 if not used). loaded with the scene, used in Awake().

◆ Synchronization

ViewSynchronization Photon.Pun.PhotonView.Synchronization = ViewSynchronization.UnreliableOnChange

Property Documentation

◆ AmController

bool Photon.Pun.PhotonView.AmController
get

◆ AmOwner

bool Photon.Pun.PhotonView.AmOwner
get

◆ Controller

Player Photon.Pun.PhotonView.Controller
get

◆ ControllerActorNr

int Photon.Pun.PhotonView.ControllerActorNr
getset

◆ CreatorActorNr

int Photon.Pun.PhotonView.CreatorActorNr
get

◆ InstantiationData

object [] Photon.Pun.PhotonView.InstantiationData
getset

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

◆ IsMine

bool Photon.Pun.PhotonView.IsMine
get

True if the PhotonView is "mine" and can be controlled by this client.

PUN has an ownership concept that defines who can control and destroy each PhotonView. True in case the controller matches the local Player. True if this is a scene photonview (null owner and ownerId == 0) on the Master client.

◆ IsOwnerActive

bool Photon.Pun.PhotonView.IsOwnerActive
get

◆ IsRoomView

bool Photon.Pun.PhotonView.IsRoomView
get

True if the PhotonView was loaded with the scene (game object) or instantiated with InstantiateRoomObject.

Room 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 ownerId is 0 (player IDs are 1 and up).

◆ IsSceneView

bool Photon.Pun.PhotonView.IsSceneView
get

◆ Owner

Player Photon.Pun.PhotonView.Owner
get

The owner of a PhotonView is the creator of an object by default Ownership can be transferred and the owner may not be in the room anymore. Objects in the scene don't have an owner.

The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.

Ownership can be transferred to another player with PhotonView.TransferOwnership or any player can request ownership by calling the PhotonView's RequestOwnership method. The current owner has to implement IPunCallbacks.OnOwnershipRequest to react to the ownership request.

◆ OwnerActorNr

int Photon.Pun.PhotonView.OwnerActorNr
getset

◆ Prefix

int Photon.Pun.PhotonView.Prefix
getset

◆ ViewID

int Photon.Pun.PhotonView.ViewID
getset

The ID of the PhotonView. Identifies it in a networked game (per room).

See: Network Instantiation


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