Help









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

Featured Snippets


File name: ChatGui.cs Copy
215     private void GuiSendsMsg()
216     {
217         if (string.IsNullOrEmpty(this.inputLine))
218         {
219
220             GUI.FocusControl("");
221             return;
222         }
223
224         if (this.inputLine[0].Equals('\\'))
225         {
226             string[] tokens = this.inputLine.Split(new char[] {' '}, 2);
227             if (tokens[0].Equals("\\help"))
228             {
229                 this.PostHelpToCurrentChannel();
230             }
231             if (tokens[0].Equals("\\state"))
232             {
233                 int newState = int.Parse(tokens[1]);
234                 this.chatClient.SetOnlineStatus(newState, new string[] { "i am state " + newState }); // this is how you set your own state and (any) message
235             }
236             else if (tokens[0].Equals("\\subscribe") && !string.IsNullOrEmpty(tokens[1]))
237             {
238                 this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
239             }
240             else if (tokens[0].Equals("\\unsubscribe") && !string.IsNullOrEmpty(tokens[1]))
241             {
242                 this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
243             }
244             else if (tokens[0].Equals("\\clear"))
245             {
246                 if (this.doingPrivateChat)
247                 {
248                     this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
249                 }
250                 else
251                 {
252                     ChatChannel channel;
253                     if (this.chatClient.TryGetChannel(this.selectedChannelName, this.doingPrivateChat, out channel))
254                     {
255                         channel.ClearMessages();
256                     }
257                 }
258             }
259             else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
260             {
261                 string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
262                 string targetUser = subtokens[0];
263                 string message = subtokens[1];
264                 this.chatClient.SendPrivateMessage(targetUser, message);
265             }
266         }
267         else
268         {
269             if (this.doingPrivateChat)
270             {
271                 this.chatClient.SendPrivateMessage(this.userIdInput, this.inputLine);
272             }
273             else
274             {
275                 this.chatClient.PublishMessage(this.selectedChannelName, this.inputLine);
276             }
277         }
278
279         this.inputLine = "";
280         GUI.FocusControl("");
281     }
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: NamePickGui.cs Copy
38     public void OnGUI()
39     {
40         // Enter-Key handling:
41         if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
42         {
43             if (!string.IsNullOrEmpty(this.InputLine))
44             {
45                 this.StartChat();
46                 return;
47             }
48         }
49
50
51         GUI.skin.label.wordWrap = true;
52         GUILayout.BeginArea(guiCenteredRect);
53
54
55         if (this.chatComponent != null && string.IsNullOrEmpty(this.chatComponent.ChatAppId))
56         {
57             GUILayout.Label("To continue, configure your Chat AppId.\nIt's listed in the Chat Dashboard (online).\nStop play-mode and edit:\nScripts/ChatGUI in the Hierarchy.");
58             if (GUILayout.Button("Open Chat Dashboard"))
59             {
60                 Application.OpenURL("https://www.exitgames.com/en/Chat/Dashboard");
61             }
62             GUILayout.EndArea();
63             return;
64         }
65
66         GUILayout.Label(this.helpText);
67
68         GUILayout.BeginHorizontal();
69         GUI.SetNextControlName("NameInput");
70         this.InputLine = GUILayout.TextField(this.InputLine);
71         if (GUILayout.Button("Connect", GUILayout.ExpandWidth(false)))
72         {
73             this.StartChat();
74         }
75         GUILayout.EndHorizontal();
76
77         GUILayout.EndArea();
78
79
80         GUI.FocusControl("NameInput");
81     }
File name: GUICustomAuth.cs Copy
42     enum GuiState { AuthOrNot, AuthInput, AuthHelp, AuthFailed }
File name: GUICustomAuth.cs Copy
52     public void SetStateAuthHelp()
53     {
54         RootOf3dButtons.SetActive(false);
55         guiState = GuiState.AuthHelp;
56     }
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: PhotonTransformViewEditor.cs Copy
96     private void DrawSynchronizePositionData()
97     {
98         if (this.m_SynchronizePositionProperty == null || this.m_SynchronizePositionProperty.boolValue == false)
99         {
100             return;
101         }
102
103         SerializedProperty interpolatePositionProperty = serializedObject.FindProperty("m_PositionModel.InterpolateOption");
104         PhotonTransformViewPositionModel.InterpolateOptions interpolateOption = (PhotonTransformViewPositionModel.InterpolateOptions)interpolatePositionProperty.enumValueIndex;
105
106         SerializedProperty extrapolatePositionProperty = serializedObject.FindProperty("m_PositionModel.ExtrapolateOption");
107         PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption = (PhotonTransformViewPositionModel.ExtrapolateOptions)extrapolatePositionProperty.enumValueIndex;
108
109         float containerHeight = 155;
110
111         switch (interpolateOption)
112         {
113             case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
114             case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
115                 containerHeight += EDITOR_LINE_HEIGHT;
116                 break;
117             /*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
118                 containerHeight += EDITOR_LINE_HEIGHT*3;
119                 break;*/
120         }
121
122         if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
123         {
124             containerHeight += EDITOR_LINE_HEIGHT;
125         }
126
127         switch (extrapolateOption)
128         {
129             case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
130                 containerHeight += EDITOR_LINE_HEIGHT;
131                 break;
132         }
133
134         if (this.m_InterpolateHelpOpen == true)
135         {
136             containerHeight += GetInterpolateHelpBoxHeight();
137         }
138
139         if (this.m_ExtrapolateHelpOpen == true)
140         {
141             containerHeight += GetExtrapolateHelpBoxHeight();
142         }
143
144         // removed Gizmo Options. -3 lines, -1 splitter
145         containerHeight -= EDITOR_LINE_HEIGHT * 2;
146
147         Rect rect = PhotonGUI.ContainerBody(containerHeight);
148
149         Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
150
151         DrawTeleport(ref propertyRect);
152         DrawSplitter(ref propertyRect);
153
154         DrawSynchronizePositionDataInterpolation(ref propertyRect, interpolatePositionProperty, interpolateOption);
155         DrawSplitter(ref propertyRect);
156
157         DrawSynchronizePositionDataExtrapolation(ref propertyRect, extrapolatePositionProperty, extrapolateOption);
158         DrawSplitter(ref propertyRect);
159
160         DrawSynchronizePositionDataGizmos(ref propertyRect);
161     }
File name: PhotonTransformViewEditor.cs Copy
163     private float GetInterpolateHelpBoxHeight()
164     {
165         return PhotonGUI.RichLabel.CalcHeight(new GUIContent(INTERPOLATE_HELP), Screen.width - 54) + 35;
166     }
File name: PhotonTransformViewEditor.cs Copy
168     private float GetExtrapolateHelpBoxHeight()
169     {
170         return PhotonGUI.RichLabel.CalcHeight(new GUIContent(EXTRAPOLATE_HELP), Screen.width - 54) + 35;
171     }
File name: PhotonTransformViewEditor.cs Copy
203     private void DrawHelpBox(ref Rect propertyRect, bool isOpen, float height, string helpText, string url)
204     {
205         if (isOpen == true)
206         {
207             Rect helpRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width, height - 5);
208             GUI.BeginGroup(helpRect, GUI.skin.box);
209             GUI.Label(new Rect(5, 5, propertyRect.width - 10, height - 30), helpText, PhotonGUI.RichLabel);
210             if (GUI.Button(new Rect(5, height - 30, propertyRect.width - 10, 20), "Read more in our documentation"))
211             {
212                 Application.OpenURL(url);
213             }
214             GUI.EndGroup();
215
216             propertyRect.y += height;
217         }
218     }

Download file with original file name:Help

Help 199 lượt xem

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