Joined
How do I use Joined
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: Demo2DJumpAndRun.cs
Copy
6 void OnJoinedRoom()
7 {
8 if( PhotonNetwork.isMasterClient == false )
9 {
10 return;
11 }
12
13 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 5.5f, 0 ), Quaternion.identity, 0, null );
14 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 4.5f, 0 ), Quaternion.identity, 0, null );
15 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( -4.5f, 3.5f, 0 ), Quaternion.identity, 0, null );
16
17 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 5.5f, 0 ), Quaternion.identity, 0, null );
18 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 4.5f, 0 ), Quaternion.identity, 0, null );
19 PhotonNetwork.InstantiateSceneObject( "Physics Box", new Vector3( 4.5f, 3.5f, 0 ), Quaternion.identity, 0, null );
20 }
File name: InstantiateCube.cs
Copy
12 void OnClick()
13 {
14 if (PhotonNetwork.connectionStateDetailed != PeerState.Joined)
15 {
16 // only use PhotonNetwork.Instantiate while in a room.
17 return;
18 }
19
20 switch (InstantiateType)
21 {
22 case 0:
23 PhotonNetwork.Instantiate(Prefab.name, this.transform.position + 3*Vector3.up, Quaternion.identity, 0);
24 break;
25 case 1:
26 PhotonNetwork.InstantiateSceneObject(Prefab.name, InputToEvent.inputHitPos + new Vector3(0, 5f, 0), Quaternion.identity, 0, null);
27 break;
28 }
29 }
File name: OnJoinInstantiate.cs
Copy
13 public void OnJoinedRoom()
14 {
15 Vector3 pos = Vector3.zero;
16 pos.x += PhotonNetwork.player.ID;
17
18 if (!InstantiateSceneObjects)
19 {
20
21 newObj = PhotonNetwork.Instantiate(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
22
23
24 // anything you do with newObj locally is not reflected on the other clients.
25 // you can add a script to the Prefab to do some instantiation in Awake() and you can call RPCs on newObj now.
26 }
27 else
28 {
29 newObj = PhotonNetwork.InstantiateSceneObject(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
30 //PhotonView pv = newObj.GetComponent
31 //Debug.Log(pv.ownerId + " " + pv.viewID);
32 }
33 }
File name: GUICustomAuth.cs
Copy
19 public void OnJoinedLobby()
20 {
21 // for ease of use, this script simply deactivates itself on successful connect
22 this.enabled = false;
23 }
File name: GUIFriendsInRoom.cs
Copy
15 public void OnGUI()
16 {
17 if (PhotonNetwork.connectionStateDetailed != PeerState.Joined)
18 {
19 return;
20 }
21
22 GUILayout.BeginArea(GuiRect);
23
24 GUILayout.Label("In-Game");
25 GUILayout.Label("For simplicity, this demo just shows the players in this room. The list will expand when more join.");
26 GUILayout.Label("Your (random) name: " + PhotonNetwork.playerName);
27 GUILayout.Label(PhotonNetwork.playerList.Length + " players in this room.");
28 GUILayout.Label("The others are:");
29 foreach (PhotonPlayer player in PhotonNetwork.otherPlayers)
30 {
31 GUILayout.Label(player.ToString());
32 }
33
34 if (GUILayout.Button("Leave"))
35 {
36 PhotonNetwork.LeaveRoom();
37 }
38 GUILayout.EndArea();
39 }
File name: DemoMecanimGUI.cs
Copy
187 public override void OnJoinedRoom()
188 {
189 CreatePlayerObject();
190 }
File name: IELdemo.cs
Copy
33 // This is one of the callback/event methods called by PUN (read more in PhotonNetworkingMessage enumeration)
34 public void OnJoinedRoom()
35 {
36 }
File name: WorkerMenu.cs
Copy
200 public void OnJoinedRoom()
201 {
202 Debug.Log("OnJoinedRoom");
203 }
Download file with original file name:Joined
Joined 116 lượt xem
Gõ tìm kiếm nhanh...