RequestOwnership
How do I use Request Ownership
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
23 | this.photonView.RequestOwnership(); | 1 |
2642 | internal protected void RequestOwnership(int viewID, int fromOwner) | 2 |
261 | public void RequestOwnership() | 3 |
File name: OnClickRequestOwnership.cs
Copy
8 public void OnClick()
9 {
10 if( Input.GetKey( KeyCode.LeftShift ) || Input.GetKey( KeyCode.RightShift ) )
11 {
12 Vector3 colVector = new Vector3( Random.Range( 0.0f, 1.0f ), Random.Range( 0.0f, 1.0f ), Random.Range( 0.0f, 1.0f ) );
13 this.photonView.RPC( "ColorRpc", PhotonTargets.AllBufferedViaServer, colVector );
14 }
15 else
16 {
17 if( this.photonView.ownerId == PhotonNetwork.player.ID )
18 {
19 Debug.Log( "Not requesting ownership. Already mine." );
20 return;
21 }
22
23 this.photonView.RequestOwnership();
24 }
25 }
File name: NetworkingPeer.cs
Copy
2642 internal protected void RequestOwnership(int viewID, int fromOwner)
2643 {
2644 Debug.Log("RequestOwnership(): " + viewID + " from: " + fromOwner + " Time: " + Environment.TickCount % 1000);
2645 //PhotonNetwork.networkingPeer.OpRaiseEvent(PunEvent.OwnershipRequest, true, new int[] { viewID, fromOwner }, 0, EventCaching.DoNotCache, null, ReceiverGroup.All, 0);
2646 this.OpRaiseEvent(PunEvent.OwnershipRequest, new int[] {viewID, fromOwner}, true, new RaiseEventOptions() { Receivers = ReceiverGroup.All }); // All sends to all via server (including self)
2647 }
File name: PhotonView.cs
Copy
261 public void RequestOwnership()
262 {
263 PhotonNetwork.networkingPeer.RequestOwnership(this.viewID, this.ownerId);
264 }
Download file with original file name:RequestOwnership
RequestOwnership 127 lượt xem
Gõ tìm kiếm nhanh...