PREV
How do I use P R E V
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ChatGui.cs
Copy
103 public void OnGUI()
104 {
105 if (!this.IsVisible)
106 {
107 return;
108 }
109
110 GUI.skin.label.wordWrap = true;
111 //GUI.skin.button.richText = true; // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
112 //GUILayout.Button("lala"); // as richText, html tags could be in text
113
114
115 if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
116 {
117 if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
118 {
119 // focus on input -> submit it
120 GuiSendsMsg();
121 return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
122 }
123 else
124 {
125 // assign focus to input
126 GUI.FocusControl("ChatInput");
127 }
128 }
129
130 GUI.SetNextControlName("");
131 GUILayout.BeginArea(this.GuiRect);
132
133 GUILayout.FlexibleSpace();
134
135 if (this.chatClient.State != ChatState.ConnectedToFrontEnd)
136 {
137 GUILayout.Label("Not in chat yet.");
138 }
139 else
140 {
141 List
142 int countOfPublicChannels = channels.Count;
143 channels.AddRange(this.chatClient.PrivateChannels.Keys);
144
145 if (channels.Count > 0)
146 {
147 int previouslySelectedChannelIndex = this.selectedChannelIndex;
148 int channelIndex = channels.IndexOf(this.selectedChannelName);
149 this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;
150
151 this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
152 this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
153
154 this.doingPrivateChat = (this.selectedChannelIndex >= countOfPublicChannels);
155 this.selectedChannelName = channels[this.selectedChannelIndex];
156
157 if (this.selectedChannelIndex != previouslySelectedChannelIndex)
158 {
159 // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
160 this.scrollPos.y = float.MaxValue;
161 if (this.doingPrivateChat)
162 {
163 string[] pieces = this.selectedChannelName.Split(new char[] {':'}, 3);
164 this.userIdInput = pieces[1];
165 }
166 }
167
168 GUILayout.Label(ChatGui.WelcomeText);
169
170 if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
171 {
172 for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
173 {
174 string sender = this.selectedChannel.Senders[i];
175 object message = this.selectedChannel.Messages[i];
176 GUILayout.Label(string.Format("{0}: {1}", sender, message));
177 }
178 }
179
180 GUILayout.EndScrollView();
181 }
182 }
183
184
185 GUILayout.BeginHorizontal();
186 if (doingPrivateChat)
187 {
188 GUILayout.Label("to:", GUILayout.ExpandWidth(false));
189 GUI.SetNextControlName("WhisperTo");
190 this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
191 string focussed = GUI.GetNameOfFocusedControl();
192 if (focussed.Equals("WhisperTo"))
193 {
194 if (this.userIdInput.Equals("username"))
195 {
196 this.userIdInput = "";
197 }
198 }
199 else if (string.IsNullOrEmpty(this.userIdInput))
200 {
201 this.userIdInput = "username";
202 }
203
204 }
205 GUI.SetNextControlName("ChatInput");
206 inputLine = GUILayout.TextField(inputLine);
207 if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
208 {
209 GuiSendsMsg();
210 }
211 GUILayout.EndHorizontal();
212 GUILayout.EndArea();
213 }
File name: GUICustomAuth.cs
Copy
70 public void ConnectWithNickname()
71 {
72 RootOf3dButtons.SetActive(false);
73
74 PhotonNetwork.AuthValues = null; // null by default but maybe set in a previous session.
75 PhotonNetwork.ConnectUsingSettings("1.0");
76
77 // PhotonNetwork.playerName gets set in GUIFriendFinding
78 // a UserID is not used in this case (no AuthValues set)
79 }
File name: OptionsScript.cs
Copy
108 private void setOption(string optionKey, bool optionBoolValue) {
109 //convert bool to int
110 int optionIntValue;
111 if (optionBoolValue == true) {
112 optionIntValue = 1;
113 }
114 else {
115 optionIntValue = 0;
116 }
117
118 //set the Player Prefis Value
119 PlayerPrefs.SetInt ("options_" + optionKey,optionIntValue);
120 PlayerPrefs.Save();
121
122 //I want to do this but getting a null reference exception for "this" argh!!
123 //GetType().GetProperty(optionKey).SetValue(this, optionBoolValue, null);
124 //GetType().GetProperty("previous_" + optionKey).SetValue(this, optionBoolValue, null);
125
126 if(optionKey == "use_0") {
127 this.use_0 = optionBoolValue;
128 this.previous_use_0 = optionBoolValue;
129 }
130 if(optionKey == "play_sounds") {
131 this.play_sounds = optionBoolValue;
132 this.previous_play_sounds = optionBoolValue;
133 }
134 }
File name: OptionsScript.cs
Copy
137 private void setOption(string optionKey, string optionStringValue) {
138 //set the Player Prefis Value
139 PlayerPrefs.SetString ("options_" + optionKey, optionStringValue);
140 PlayerPrefs.Save();
141
142 //I want to do this but getting a null reference exception for "this" argh!!
143 //GetType().GetProperty(optionKey).SetValue(this, optionBoolValue, null);
144 //GetType().GetProperty("previous_" + optionKey).SetValue(this, optionBoolValue, null);
145
146 if(optionKey == "board_type") {
147 this.board_type = optionStringValue;
148 this.previous_board_type = optionStringValue;
149 }
150 }
File name: OptionsScript.cs
Copy
153 private void setOption(string optionKey, int optionValue) {
154 //set the Player Prefis Value
155 PlayerPrefs.SetInt ("options_" + optionKey, optionValue);
156 PlayerPrefs.Save();
157
158 //I want to do this but getting a null reference exception for "this" argh!!
159 //GetType().GetProperty(optionKey).SetValue(this, optionBoolValue, null);
160 //GetType().GetProperty("previous_" + optionKey).SetValue(this, optionBoolValue, null);
161
162 if(optionKey == "timer_duration") {
163 this.timer_duration = optionValue;
164 this.previous_timer_duration = optionValue;
165 }
166 }
File name: OptionsScript.cs
Copy
168 void OnGUI() {
169 if (this.gameScript.gameView == "options") {
170 this.gameScript.mainCamera.transform.eulerAngles = new Vector3 (120, 23, 0);
171
172 GUI.skin = this.gameScript.currentGUISkin;
173
174 //check to see if any options changed
175 if (previous_use_0 != use_0) {
176 this.setOption ("use_0", this.use_0);
177 GameControllerScript.performRestart = true;
178 }
179
180 if (this.previous_board_type != this.board_type) {
181 this.setOption ("board_type", this.board_type);
182 GameControllerScript.performRestart = true;
183 }
184
185 if (previous_play_sounds != play_sounds) {
186 this.setOption ("play_sounds", this.play_sounds);
187 }
188
189 if (this.previous_timer_duration != this.timer_duration) {
190 this.setOption ("timer_duration", this.timer_duration);
191 GameControllerScript.performRestart = true;
192 }
193
194
195
196 //set the label
197 GUILayout.Label ("Options", "BigLabel");
198
199 scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Mathf.Ceil(Screen.height * .80f)));
200
201
202
203 //Sounds
204 GUILayout.BeginHorizontal ();
205 if (GUILayout.Toggle (this.play_sounds, "Play Sounds", currentGUISkin.toggle)) {
206 this.play_sounds = true;
207 }
208 else {
209 this.play_sounds = false;
210 }
211 GUILayout.Label ( "Play Sounds", "ToggleLabel");
212 GUILayout.EndHorizontal();
213
214
215 GUILayout.Label ("WARNING! Changing any of the following options will cause the game to reset!", "ToggleLabelWarning");
216
217 GUILayout.Label ("Game Board Type", "Subheader");
218 //Game Board Type
219 GUILayout.BeginHorizontal ();
220 if (GUILayout.Toggle (this.board_type == "Solid Cube", "Solid Cube", currentGUISkin.toggle)) {
221 this.board_type = "Solid Cube";
222 }
223 GUILayout.Label ( "Solid Cube (27 Blocks)", "ToggleLabel");
224 GUILayout.EndHorizontal();
225
226
227 GUILayout.BeginHorizontal ();
228 if (GUILayout.Toggle (this.board_type == "Hollow Cube", "Hollow Cube", currentGUISkin.toggle)) {
229 this.board_type = "Hollow Cube";
230 }
231 GUILayout.Label ( "Hollow Cube (26 Blocks)", "ToggleLabel");
232 GUILayout.EndHorizontal();
233
234
235 GUILayout.BeginHorizontal ();
236 if (GUILayout.Toggle (this.board_type == "Four Walls", "Four Walls", currentGUISkin.toggle)) {
237 this.board_type = "Four Walls";
238 }
239 GUILayout.Label ( "Four Walls (24 Blocks)", "ToggleLabel");
240 GUILayout.EndHorizontal();
241
242
243 GUILayout.BeginHorizontal ();
244 if (GUILayout.Toggle (this.board_type == "Box Outline", "Box Outline", currentGUISkin.toggle)) {
245 this.board_type = "Box Outline";
246 }
247 GUILayout.Label ( "Cube Outline (20 Blocks)", "ToggleLabel");
248 GUILayout.EndHorizontal();
249
250
251
252 GUILayout.BeginHorizontal ();
253 if (GUILayout.Toggle (this.board_type == "No Corners", "No Corners", currentGUISkin.toggle)) {
254 this.board_type = "No Corners";
255 }
256 GUILayout.Label ( "No Corners (19 Blocks)", "ToggleLabel");
257 GUILayout.EndHorizontal();
258
259
260 GUILayout.BeginHorizontal ();
261 if (GUILayout.Toggle (this.board_type == "No Corners/Center", "No Corners/Center", currentGUISkin.toggle)) {
262 this.board_type = "No Corners/Center";
263 }
264 GUILayout.Label ( "No Corners/Center (18 Blocks)", "ToggleLabel");
265 GUILayout.EndHorizontal();
266
267
268 //TIMER OPTIONS ####################################################
269 GUILayout.Label ("Timer", "Subheader");
270
271 foreach (int i in this.GetTimerDurationTimes())
272 {
273 GUILayout.BeginHorizontal ();
274 if (GUILayout.Toggle (this.timer_duration == i, "", currentGUISkin.toggle)) {
275 this.timer_duration = i;
276 }
277 GUILayout.Label (TimerDurationToString (i), "ToggleLabel");
278 GUILayout.EndHorizontal();
279 }
280
281
282
283
284 //Other OPTIONS ####################################################
285 GUILayout.Label ("Block Numbers", "Subheader");
286
287 //Use Zeros
288 GUILayout.BeginHorizontal ();
289 if (GUILayout.Toggle (use_0, "Use 0s (Note: Changing this will reset the current game!)", currentGUISkin.toggle)) {
290 use_0 = true;
291 }
292 else {
293 use_0 = false;
294 }
295 GUILayout.Label ( "Use Zeros", "ToggleLabel");
296 GUILayout.EndHorizontal();
297
298
299
300 foreach (Touch touch in Input.touches) {
301 if (touch.phase == TouchPhase.Moved)
302 {
303 // dragging
304 scrollPosition.y += touch.deltaPosition.y;
305 }
306 }
307
308 GUILayout.EndScrollView();
309
310 if (GUILayout.Button ("Return to Menu", "Button")) {
311 gameScript.gameView = "menu";
312 }
313 }
314 }
File name: Form1.cs
Copy
293 public void PREV_Click(System.Object sender, System.EventArgs e)
294 {
295
296 dsgrade = gradeclass.DataModule.navigate();
297 if (inc > 0)
298 {
299 inc--;
300 NavRecords();
301 }
302 else if (inc == -1)
303 {
304 MessageBox.Show("No Records Yet");
305 }
306 else if (inc == 0)
307 {
308 MessageBox.Show("First Record");
309 }
310
311
312 }
File name: GameplayController.cs
Copy
70 void InitializeVariables(){
71 gameInProgress = true;
72 enemies = new List
73 objects = new List
74 distance = 10f;
75 if(GameController.instance != null){
76 GameController.instance.score = 0;
77 prevLevel = GameController.instance.currentLevel;
78 highscore.transform.GetChild (0).transform.GetComponent
79
80 if(GameController.instance.highscore[GameController.instance.currentLevel - 1] > 0){
81 highscore.gameObject.SetActive (true);
82 }
83
84 }
85
86 }
File name: GameplayController.cs
Copy
242 public void RestartGame(){
243 SceneManager.LoadScene (SceneManager.GetActiveScene().buildIndex);
244 if(GameController.instance != null){
245 GameController.instance.currentLevel = prevLevel;
246 }
247 }
File name: HorizontalScrollSnap.cs
Copy
200 public void OnEndDrag(PointerEventData eventData)
201 {
202 _pointerDown = false;
203
204 if (_scroll_rect.horizontal)
205 {
206 if (UseFastSwipe)
207 {
208 //If using fastswipe - then a swipe does page next / previous
209 if ((_scroll_rect.velocity.x > 0 &&_scroll_rect.velocity.x > FastSwipeThreshold) ||
210 _scroll_rect.velocity.x < 0 && _scroll_rect.velocity.x < -FastSwipeThreshold)
211 {
212 _scroll_rect.velocity = Vector3.zero;
213 if (_startPosition.x - _screensContainer.localPosition.x > 0)
214 {
215 NextScreen();
216 }
217 else
218 {
219 PreviousScreen();
220 }
221 }
222 else
223 {
224 ScrollToClosestElement();
225 }
226 }
227 }
228 }
Download file with original file name:PREV
PREV 115 lượt xem
Gõ tìm kiếm nhanh...