Debug









How do I use Debug
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: DemoOwnershipGui.cs Copy
8     public void OnOwnershipRequest(object[] viewAndPlayer)
9     {
10         PhotonView view = viewAndPlayer[0] as PhotonView;
11         PhotonPlayer requestingPlayer = viewAndPlayer[1] as PhotonPlayer;
12
13         Debug.Log("OnOwnershipRequest(): Player " + requestingPlayer + " requests ownership of: " + view + ".");
14         if (this.TransferOwnershipOnRequest)
15         {
16             view.TransferOwnership(requestingPlayer.ID);
17         }
18     }
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: OnClickRightDestroy.cs Copy
5     public void OnPressRight()
6     {
7         Debug.Log("RightClick Destroy");
8         PhotonNetwork.Destroy(gameObject);
9     }
File name: ChatGui.cs Copy
58     public void Start()
59     {
60         DontDestroyOnLoad(this.gameObject);
61         Application.runInBackground = true; // this must run in background or it will drop connection if not focussed.
62
63         if (string.IsNullOrEmpty(this.UserName))
64         {
65             this.UserName = "user" + Environment.TickCount%99; //made-up username
66         }
67
68         chatClient = new ChatClient(this);
69         chatClient.Connect(ChatAppId, "1.0", this.UserName, null);
70
71         if (this.AlignBottom)
72         {
73             this.GuiRect.y = Screen.height - this.GuiRect.height;
74         }
75         if (this.FullScreen)
76         {
77             this.GuiRect.x = 0;
78             this.GuiRect.y = 0;
79             this.GuiRect.width = Screen.width;
80             this.GuiRect.height = Screen.height;
81         }
82
83         Debug.Log(this.UserName);
84     }
File name: ChatGui.cs Copy
283     private void PostHelpToCurrentChannel()
284     {
285         ChatChannel channelForHelp = this.selectedChannel;
286         if (channelForHelp != null)
287         {
288             channelForHelp.Add("info", ChatGui.HelpText);
289         }
290         else
291         {
292             Debug.LogError("no channel for help");
293         }
294     }
File name: ChatGui.cs Copy
348     public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
349     {
350         // this is how you get status updates of friends.
351         // this demo simply adds status updates to the currently shown chat.
352         // you could buffer them or use them any other way, too.
353
354         ChatChannel activeChannel = this.selectedChannel;
355         if (activeChannel != null)
356         {
357             activeChannel.Add("info", string.Format("{0} is {1}. Msg:{2}", user, status, message));
358         }
359
360         Debug.LogWarning("status: " + string.Format("{0} is {1}. Msg:{2}", user, status, message));
361     }
File name: NamePickGui.cs Copy
15     public void Awake()
16     {
17         this.guiCenteredRect = new Rect(Screen.width/2-GuiSize.x/2, Screen.height/2-GuiSize.y/4, GuiSize.x, GuiSize.y);
18         this.chatComponent = this.GetComponent();
19
20         if (this.chatComponent != null && chatComponent.enabled)
21         {
22             Debug.LogWarning("When using the NamePickGui, ChatGui should be disabled initially.");
23
24             if (this.chatComponent.chatClient != null)
25             {
26                 this.chatComponent.chatClient.Disconnect();
27             }
28             this.chatComponent.enabled = false;
29         }
30
31         string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);
32         if (!string.IsNullOrEmpty(prefsName))
33         {
34             this.InputLine = prefsName;
35         }
36     }
File name: GUICustomAuth.cs Copy
35     public void OnCustomAuthenticationFailed(string debugMessage)
36     {
37         this.authDebugMessage = debugMessage;
38         SetStateAuthFailed();
39     }
File name: GUICustomAuth.cs Copy
81     void OnGUI()
82     {
83         if (PhotonNetwork.connected)
84         {
85             GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
86             return;
87         }
88
89
90         GUILayout.BeginArea(GuiRect);
91         switch (guiState)
92         {
93             case GuiState.AuthFailed:
94                 GUILayout.Label("Authentication Failed");
95
96                 GUILayout.Space(10);
97
98                 GUILayout.Label("Error message:\n'" + this.authDebugMessage + "'");
99
100                 GUILayout.Space(10);
101
102                 GUILayout.Label("For this demo set the Authentication URL in the Dashboard to:\nhttp://photon.webscript.io/auth-demo-equals");
103                 GUILayout.Label("That authentication-service has no user-database. It confirms any user if 'name equals password'.");
104                 GUILayout.Label("The error message comes from that service and can be customized.");
105
106                 GUILayout.Space(10);
107
108                 GUILayout.BeginHorizontal();
109                 if (GUILayout.Button("Back"))
110                 {
111                     SetStateAuthInput();
112                 }
113                 if (GUILayout.Button("Help"))
114                 {
115                     SetStateAuthHelp();
116                 }
117                 GUILayout.EndHorizontal();
118                 break;
119
120             case GuiState.AuthHelp:
121
122                 GUILayout.Label("By default, any player can connect to Photon.\n'Custom Authentication' can be enabled to reject players without valid user-account.");
123
124                 GUILayout.Label("The actual authentication must be done by a web-service which you host and customize. Example sourcecode for these services is available on the docs page.");
125
126                 GUILayout.Label("For this demo set the Authentication URL in the Dashboard to:\nhttp://photon.webscript.io/auth-demo-equals");
127                 GUILayout.Label("That authentication-service has no user-database. It confirms any user if 'name equals password'.");
128
129                 GUILayout.Space(10);
130                 if (GUILayout.Button("Configure Authentication (Dashboard)"))
131                 {
132                     Application.OpenURL("https://cloud.exitgames.com/dashboard");
133                 }
134                 if (GUILayout.Button("Authentication Docs"))
135                 {
136                     Application.OpenURL("https://doc.exitgames.com/en/pun/current/tutorials/pun-and-facebook-custom-authentication");
137                 }
138
139
140                 GUILayout.Space(10);
141                 if (GUILayout.Button("Back to input"))
142                 {
143                     SetStateAuthInput();
144                 }
145                 break;
146
147             case GuiState.AuthInput:
148
149                 GUILayout.Label("Authenticate yourself");
150
151                 GUILayout.BeginHorizontal();
152                 this.authName = GUILayout.TextField(this.authName, GUILayout.Width(Screen.width/4 - 5));
153                 GUILayout.FlexibleSpace();
154                 this.authToken = GUILayout.TextField(this.authToken, GUILayout.Width(Screen.width/4 - 5));
155                 GUILayout.EndHorizontal();
156
157
158                 if (GUILayout.Button("Authenticate"))
159                 {
160                     PhotonNetwork.AuthValues = new AuthenticationValues();
161                     PhotonNetwork.AuthValues.SetAuthParameters(this.authName, this.authToken);
162                     PhotonNetwork.ConnectUsingSettings("1.0");
163                 }
164
165                 GUILayout.Space(10);
166
167                 if (GUILayout.Button("Help", GUILayout.Width(100)))
168                 {
169                     SetStateAuthHelp();
170                 }
171
172                 break;
173         }
174
175         GUILayout.EndArea();
176     }
File name: GUIFriendFinding.cs Copy
46     public void OnUpdatedFriendList()
47     {
48         Debug.Log("OnUpdatedFriendList is called when the list PhotonNetwork.Friends is refreshed.");
49     }

Download file with original file name:Debug

Debug 194 lượt xem

Gõ tìm kiếm nhanh...