A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances. More...
Inherits MonoBehaviour.
Public Types | |
enum | ObservableSearch |
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. | |
List< Component > | ObservedComponents |
int | sceneViewId = 0 |
This field is the Scene ViewID (0 if not used). loaded with the scene, used in Awake(). | |
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... | |
A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances.
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.
T | : | class | |
T | : | IPhotonViewCallback |
void AddCallbackTarget | ( | IPhotonViewCallback | obj | ) |
Add object to all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface.
obj | An object that implements OnPhotonView callback interface(s). |
|
static |
Finds the PhotonView Component with a viewID in the scene
viewID |
void 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.
force | If true, FindObservables will work as if observableSearch is AutoFindActive. |
void 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.
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.
T | : | class | |
T | : | IPhotonViewCallback |
void RemoveCallbackTarget | ( | IPhotonViewCallback | obj | ) |
Remove object from all applicable callback interfaces. Object must implement at least one IOnPhotonViewCallback derived interface.
obj | An object that implements OnPhotonView callback interface(s). |
void 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.
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).
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.
methodName | The name of a fitting method that was has the RPC attribute. |
targetPlayer | The group of targets and the way the RPC gets sent. |
parameters | The parameters that the RPC method has (must fit this call!). |
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).
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.
methodName | The name of a fitting method that was has the RPC attribute. |
target | The group of targets and the way the RPC gets sent. |
parameters | The parameters that the RPC method has (must fit this call!). |
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).
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!).
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).
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!).
void 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.
void 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.
OwnershipOption 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.
|
getset |
This is the InstantiationData that was passed when calling PhotonNetwork.Instantiate* (if that was used to spawn this prefab)
|
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.
|
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).
|
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.
|
getset |
The ID of the PhotonView. Identifies it in a networked game (per room).
See: Network Instantiation