MaxValue
How do I use Max Value
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: ChatGui.cs
Copy
334 public void OnGetMessages(string channelName, string[] senders, object[] messages)
335 {
336 if (channelName.Equals(this.selectedChannelName))
337 {
338 this.scrollPos.y = float.MaxValue;
339 }
340 }
File name: PhotonEditor.cs
Copy
909 public static void UpdateRpcList()
910 {
911 List
912 HashSet
913
914 var types = GetAllSubTypesInScripts(typeof(MonoBehaviour));
915
916 foreach (var mono in types)
917 {
918 MethodInfo[] methods = mono.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
919
920 foreach (MethodInfo method in methods)
921 {
922 if (method.IsDefined(typeof(UnityEngine.RPC), false))
923 {
924 currentRpcs.Add(method.Name);
925
926 if (!additionalRpcs.Contains(method.Name) && !PhotonEditor.Current.RpcList.Contains(method.Name))
927 {
928 additionalRpcs.Add(method.Name);
929 }
930 }
931 }
932 }
933
934 if (additionalRpcs.Count > 0)
935 {
936 // LIMITS RPC COUNT
937 if (additionalRpcs.Count + PhotonEditor.Current.RpcList.Count >= byte.MaxValue)
938 {
939 if (currentRpcs.Count <= byte.MaxValue)
940 {
941 bool clearList = EditorUtility.DisplayDialog(CurrentLang.IncorrectRPCListTitle, CurrentLang.IncorrectRPCListLabel, CurrentLang.RemoveOutdatedRPCsLabel, CurrentLang.CancelButton);
942 if (clearList)
943 {
944 PhotonEditor.Current.RpcList.Clear();
945 PhotonEditor.Current.RpcList.AddRange(currentRpcs);
946 }
947 else
948 {
949 return;
950 }
951 }
952 else
953 {
954 EditorUtility.DisplayDialog(CurrentLang.FullRPCListTitle, CurrentLang.FullRPCListLabel, CurrentLang.SkipRPCListUpdateLabel);
955 return;
956 }
957 }
958
959 additionalRpcs.Sort();
960 PhotonEditor.Current.RpcList.AddRange(additionalRpcs);
961 EditorUtility.SetDirty(PhotonEditor.Current);
962 }
963 }
File name: NetworkingPeer.cs
Copy
690 private void CheckMasterClient(int leavingPlayerId)
691 {
692 bool currentMasterIsLeaving = this.mMasterClient != null && this.mMasterClient.ID == leavingPlayerId;
693 bool someoneIsLeaving = leavingPlayerId > 0;
694
695 // return early if SOME player (leavingId > 0) is leaving AND it's NOT the current master
696 if (someoneIsLeaving && !currentMasterIsLeaving)
697 {
698 return;
699 }
700
701 // picking the player with lowest ID (longest in game).
702 if (this.mActors.Count <= 1)
703 {
704 this.mMasterClient = this.mLocalActor;
705 }
706 else
707 {
708 // keys in mActors are their actorNumbers
709 int lowestActorNumber = Int32.MaxValue;
710 foreach (int key in this.mActors.Keys)
711 {
712 if (key < lowestActorNumber && key != leavingPlayerId)
713 {
714 lowestActorNumber = key;
715 }
716 }
717
718 this.mMasterClient = this.mActors[lowestActorNumber];
719 }
720
721 // make a callback ONLY when a player/Master left
722 if (someoneIsLeaving)
723 {
724 SendMonoMessage(PhotonNetworkingMessage.OnMasterClientSwitched, this.mMasterClient);
725 }
726 }
File name: NetworkingPeer.cs
Copy
732 private static int ReturnLowestPlayerId(PhotonPlayer[] players, int playerIdToIgnore)
733 {
734 if (players == null || players.Length == 0)
735 {
736 return -1;
737 }
738
739 int lowestActorNumber = Int32.MaxValue;
740 for (int i = 0; i < players.Length; i++)
741 {
742 PhotonPlayer photonPlayer = players[i];
743 if (photonPlayer.ID == playerIdToIgnore)
744 {
745 continue;
746 }
747
748 if (photonPlayer.ID < lowestActorNumber)
749 {
750 lowestActorNumber = photonPlayer.ID;
751 }
752 }
753
754 return lowestActorNumber;
755 }
File name: PhotonPlayer.cs
Copy
241 public PhotonPlayer GetNextFor(int currentPlayerId)
242 {
243 if (PhotonNetwork.networkingPeer == null || PhotonNetwork.networkingPeer.mActors == null || PhotonNetwork.networkingPeer.mActors.Count < 2)
244 {
245 return null;
246 }
247
248 Dictionary
249 int nextHigherId = int.MaxValue; // we look for the next higher ID
250 int lowestId = currentPlayerId; // if we are the player with the highest ID, there is no higher and we return to the lowest player's id
251
252 foreach (int playerid in players.Keys)
253 {
254 if (playerid < lowestId)
255 {
256 lowestId = playerid; // less than any other ID (which must be at least less than this player's id).
257 }
258 else if (playerid > currentPlayerId && playerid < nextHigherId)
259 {
260 nextHigherId = playerid; // more than our ID and less than those found so far.
261 }
262 }
263
264 //UnityEngine.Debug.LogWarning("Debug. " + currentPlayerId + " lower: " + lowestId + " higher: " + nextHigherId + " ");
265 //UnityEngine.Debug.LogWarning(this.RoomReference.GetPlayer(currentPlayerId));
266 //UnityEngine.Debug.LogWarning(this.RoomReference.GetPlayer(lowestId));
267 //if (nextHigherId != int.MaxValue) UnityEngine.Debug.LogWarning(this.RoomReference.GetPlayer(nextHigherId));
268 return (nextHigherId != int.MaxValue) ? players[nextHigherId] : players[lowestId];
269 }
File name: PingCloudRegions.cs
Copy
88 public static int MaxMilliseconsPerPing = 800; // enter a value you're sure some server can beat (have a lower rtt)
92 {
93 get
94 {
95 Region result = null;
96 int bestRtt = Int32.MaxValue;
97 foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
98 {
99 Debug.Log("BestRegion checks region: " + region);
100 if (region.Ping != 0 && region.Ping < bestRtt)
101 {
102 bestRtt = region.Ping;
103 result = region;
104 }
105 }
106
107 return (Region)result;
108 }
109 }
File name: BossHealth.cs
Copy
22 void InitializeBossVariables(){
23 health.maxValue = maxHealth;
24 health.value = maxHealth;
25 invulnerable = true;
26 }
File name: EnemyHealth.cs
Copy
14 void Awake(){
15 health.maxValue = maxHealth;
16 health.value = maxHealth;
17 }
File name: Cannon.cs
Copy
29 void Start () {
30 readyToShoot = true;
31 shot = maxShot;
32 timeDelay = 50;
33 minLevel = 0;
34 maxLevel = 50;
35 powerLevel.maxValue = maxLevel;
36 powerLevel.value = minLevel;
37 maxRot = 20;
38 minRot = -25;
39 Vector3 currentRotation = transform.rotation.eulerAngles;
40 }
MaxValue 125 lượt xem
Gõ tìm kiếm nhanh...