Call
How do I use Call
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ChatGui.cs
Copy
95 public void Update()
96 {
97 if (this.chatClient != null)
98 {
99 this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
100 }
101 }
File name: GUIFriendFinding.cs
Copy
46 public void OnUpdatedFriendList()
47 {
48 Debug.Log("OnUpdatedFriendList is called when the list PhotonNetwork.Friends is refreshed.");
49 }
File name: OnClickCallMethod.cs
Copy
11 public void OnClick()
12 {
13 if (this.TargetGameObject == null || string.IsNullOrEmpty(this.TargetMethod))
14 {
15 Debug.LogWarning(this + " can't call, cause GO or Method are empty.");
16 return;
17 }
18
19 this.TargetGameObject.SendMessage(this.TargetMethod);
20 }
File name: HubGui.cs
Copy
28 void OnGUI()
29 {
30 GUI.skin = this.Skin;
31 GUILayout.Space(10);
32
33 GUILayout.BeginHorizontal();
34 GUILayout.Space(10);
35 scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(320));
36
37 GUILayout.Label("Basics", m_Headline);
38 if (GUILayout.Button("Demo Boxes", GUILayout.Width(280)))
39 {
40 demoDescription = "
41 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoBoxes-Scene" };
42 }
43 if (GUILayout.Button("Demo Worker", GUILayout.Width(280)))
44 {
45 demoDescription = "
46 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoWorker-Scene" };
47 }
48 if (GUILayout.Button("Movement Smoothing", GUILayout.Width(280)))
49 {
50 demoDescription = "
51 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoSynchronization-Scene" };
52 }
53
54 GUILayout.Label("Advanced", m_Headline);
55 if (GUILayout.Button("Ownership Transfer", GUILayout.Width(280)))
56 {
57 demoDescription = "
58 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChangeOwner-Scene" };
59 this.webLink = new DemoBtn();
60 }
61 if (GUILayout.Button("Pickup, Teams, Scores", GUILayout.Width(280)))
62 {
63 demoDescription = "
64 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoPickup-Scene" };
65 this.webLink = new DemoBtn();
66 }
67
68 GUILayout.Label("Feature Demos", m_Headline);
69 if (GUILayout.Button("Chat", GUILayout.Width(280)))
70 {
71 demoDescription = "
72 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChat-Scene" };
73 this.webLink = new DemoBtn();
74 }
75 if (GUILayout.Button("RPG Movement", GUILayout.Width(280)))
76 {
77 demoDescription = "
78 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoRPGMovement-Scene" };
79 this.webLink = new DemoBtn();
80 }
81 if (GUILayout.Button("Mecanim Animations", GUILayout.Width(280)))
82 {
83 demoDescription = "
84 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoMecanim-Scene" };
85 this.webLink = new DemoBtn();
86 }
87 if (GUILayout.Button("2D Game", GUILayout.Width(280)))
88 {
89 demoDescription = "
90 this.demoBtn = new DemoBtn() { Text = "Start", Link = "Demo2DJumpAndRunWithPhysics-Scene" };
91 this.webLink = new DemoBtn();
92 }
93 if (GUILayout.Button("Friends & Authentication", GUILayout.Width(280)))
94 {
95 demoDescription = "
96 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoFriends-Scene" };
97 this.webLink = new DemoBtn();
98 }
99
100 GUILayout.Label("Tutorial", m_Headline);
101 if (GUILayout.Button("Marco Polo Tutorial", GUILayout.Width(280)))
102 {
103 demoDescription = "
104 this.demoBtn = new DemoBtn() { Text = "Start", Link = "MarcoPolo-Scene" };
105 this.webLink = new DemoBtn() { Text = "Open Tutorial (www)", Link = "http://tinyurl.com/nmylf44" };
106 }
107 GUILayout.EndScrollView();
108
109 GUILayout.BeginVertical(GUILayout.Width(Screen.width - 345));
110 GUILayout.Label(demoDescription);
111 GUILayout.Space(10);
112 if (!string.IsNullOrEmpty(this.demoBtn.Text))
113 {
114 if (GUILayout.Button(this.demoBtn.Text))
115 {
116 Application.LoadLevel(this.demoBtn.Link);
117 }
118 }
119 if (!string.IsNullOrEmpty(this.webLink.Text))
120 {
121 if (GUILayout.Button(this.webLink.Text))
122 {
123 Application.OpenURL(this.webLink.Link);
124 }
125 }
126 GUILayout.EndVertical();
127
128
129 GUILayout.EndHorizontal();
130 }
File name: CubeLerp.cs
Copy
12 public void Awake()
13 {
14 if (photonView.isMine)
15 {
16 this.enabled = false; // due to this, Update() is not called on the owner client.
17 }
18
19 latestCorrectPos = transform.position;
20 onUpdatePos = transform.position;
21 }
File name: WorkerInGame.cs
Copy
34 public void OnMasterClientSwitched(PhotonPlayer player)
35 {
36 Debug.Log("OnMasterClientSwitched: " + player);
37
38 string message;
39 InRoomChat chatComponent = GetComponent
40
41 if (chatComponent != null)
42 {
43 // to check if this client is the new master...
44 if (player.isLocal)
45 {
46 message = "You are Master Client now.";
47 }
48 else
49 {
50 message = player.name + " is Master Client now.";
51 }
52
53
54 chatComponent.AddLine(message); // the Chat method is a RPC. as we don't want to send an RPC and neither create a PhotonMessageInfo, lets call AddLine()
55 }
56 }
File name: WorkerMenu.cs
Copy
43 public void Awake()
44 {
45 // this makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
46 PhotonNetwork.automaticallySyncScene = true;
47
48 // the following line checks if this client was just created (and not yet online). if so, we connect
49 if (PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
50 {
51 // Connect to the photon master-server. We use the settings saved in PhotonServerSettings (a .asset file in this project)
52 PhotonNetwork.ConnectUsingSettings("0.9");
53 }
54
55 // generate a name for this player, if none is assigned yet
56 if (String.IsNullOrEmpty(PhotonNetwork.playerName))
57 {
58 PhotonNetwork.playerName = "Guest" + Random.Range(1, 9999);
59 }
60
61 // if you wanted more debug out, turn this on:
62 // PhotonNetwork.logLevel = NetworkLogLevel.Full;
63 }
File name: WorkerMenu.cs
Copy
206 public void OnPhotonCreateRoomFailed()
207 {
208 this.ErrorDialog = "Error: Can't create room (room name maybe already used).";
209 Debug.Log("OnPhotonCreateRoomFailed got called. This can happen if the room exists (even if not visible). Try another room name.");
210 }
File name: WorkerMenu.cs
Copy
212 public void OnPhotonJoinRoomFailed()
213 {
214 this.ErrorDialog = "Error: Can't join room (full or unknown room name).";
215 Debug.Log("OnPhotonJoinRoomFailed got called. This can happen if the room is not existing or full or closed.");
216 }
File name: WorkerMenu.cs
Copy
217 public void OnPhotonRandomJoinFailed()
218 {
219 this.ErrorDialog = "Error: Can't join random room (none found).";
220 Debug.Log("OnPhotonRandomJoinFailed got called. Happens if no room is available (or all full or invisible or closed). JoinrRandom filter-options can limit available rooms.");
221 }
Download file with original file name:Call
Call 132 lượt xem
Gõ tìm kiếm nhanh...