Size
How do I use Size
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
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: PhotonEditor.cs
Copy
294 protected void InitPhotonSetupWindow()
295 {
296 this.minSize = MinSize;
297
298 this.SwitchMenuState(GUIState.Setup);
299 this.ReApplySettingsToWindow();
300
301 switch (PhotonEditor.Current.HostType)
302 {
303 case ServerSettings.HostingOption.PhotonCloud:
304 case ServerSettings.HostingOption.BestRegion:
305 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
306 break;
307 case ServerSettings.HostingOption.SelfHosted:
308 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
309 break;
310 case ServerSettings.HostingOption.NotSet:
311 default:
312 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
313 break;
314 }
315 }
File name: PhotonGUI.cs
Copy
197 SerializedProperty gizmoSizeProperty )
198 {
199 float height = EditorGUIUtility.singleLineHeight;
200 float flexibleWidth = Mathf.Max( 40, position.width - EditorGUIUtility.labelWidth - 20 - 75 - 5 - 40 - 5 );
201
202 Rect labelRect = new Rect( position.xMin, position.yMin, EditorGUIUtility.labelWidth, height );
203 GUI.Label( labelRect, label );
204
205 Rect enabledRect = new Rect( labelRect.xMax, labelRect.yMin, 20, height );
206 EditorGUI.PropertyField( enabledRect, gizmoEnabledProperty, GUIContent.none );
207
208 bool oldGUIEnabled = GUI.enabled;
209 GUI.enabled = gizmoEnabledProperty.boolValue;
210
211 Rect colorRect = new Rect( enabledRect.xMax + 5, labelRect.yMin, 70, height );
212 EditorGUI.PropertyField( colorRect, gizmoColorProperty, GUIContent.none );
213
214 Rect typeRect = new Rect( colorRect.xMax + 5, labelRect.yMin, flexibleWidth * 0.7f, height );
215 EditorGUI.PropertyField( typeRect, gizmoTypeProperty, GUIContent.none );
216
217 Rect sizeLabelRect = new Rect( typeRect.xMax + 10, labelRect.yMin, 30, height );
218 GUI.Label( sizeLabelRect, "Size" );
219
220 Rect sizeRect = new Rect( sizeLabelRect.xMax + 5, labelRect.yMin, flexibleWidth * 0.3f, height );
221 EditorGUI.PropertyField( sizeRect, gizmoSizeProperty, GUIContent.none );
222
223 GUI.enabled = oldGUIEnabled;
224 }
File name: PhotonViewInspector.cs
Copy
258 void DrawObservedComponentsList()
259 {
260 GUILayout.Space( 5 );
261 SerializedProperty listProperty = serializedObject.FindProperty( "ObservedComponents" );
262
263 if( listProperty == null )
264 {
265 return;
266 }
267
268 float containerElementHeight = 22;
269 float containerHeight = listProperty.arraySize * containerElementHeight;
270
271 bool isOpen = PhotonGUI.ContainerHeaderFoldout( "Observed Components (" + GetObservedComponentsCount() + ")", serializedObject.FindProperty( "ObservedComponentsFoldoutOpen" ).boolValue );
272 serializedObject.FindProperty( "ObservedComponentsFoldoutOpen" ).boolValue = isOpen;
273
274 if( isOpen == false )
275 {
276 containerHeight = 0;
277 }
278
279 //Texture2D statsIcon = AssetDatabase.LoadAssetAtPath( "Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonViewStats.png", typeof( Texture2D ) ) as Texture2D;
280
281 Rect containerRect = PhotonGUI.ContainerBody( containerHeight );
282 bool wasObservedComponentsEmpty = m_Target.ObservedComponents.FindAll( item => item != null ).Count == 0;
283 if( isOpen == true )
284 {
285 for( int i = 0; i < listProperty.arraySize; ++i )
286 {
287 Rect elementRect = new Rect( containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight );
288 {
289 Rect texturePosition = new Rect( elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5 );
290 ReorderableListResources.DrawTexture( texturePosition, ReorderableListResources.texGrabHandle );
291
292 Rect propertyPosition = new Rect( elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16 );
293 EditorGUI.PropertyField( propertyPosition, listProperty.GetArrayElementAtIndex( i ), new GUIContent() );
294
295 //Debug.Log( listProperty.GetArrayElementAtIndex( i ).objectReferenceValue.GetType() );
296 //Rect statsPosition = new Rect( propertyPosition.xMax + 7, propertyPosition.yMin, statsIcon.width, statsIcon.height );
297 //ReorderableListResources.DrawTexture( statsPosition, statsIcon );
298
299 Rect removeButtonRect = new Rect( elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
300 elementRect.yMin + 2,
301 PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
302 PhotonGUI.DefaultRemoveButtonStyle.fixedHeight );
303
304 GUI.enabled = listProperty.arraySize > 1;
305 if( GUI.Button( removeButtonRect, new GUIContent( ReorderableListResources.texRemoveButton ), PhotonGUI.DefaultRemoveButtonStyle ) )
306 {
307 listProperty.DeleteArrayElementAtIndex( i );
308 }
309 GUI.enabled = true;
310
311 if( i < listProperty.arraySize - 1 )
312 {
313 texturePosition = new Rect( elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1 );
314 PhotonGUI.DrawSplitter( texturePosition );
315 }
316 }
317 }
318 }
319
320 if( PhotonGUI.AddButton() )
321 {
322 listProperty.InsertArrayElementAtIndex( Mathf.Max( 0, listProperty.arraySize - 1 ) );
323 }
324
325 serializedObject.ApplyModifiedProperties();
326
327 bool isObservedComponentsEmpty = m_Target.ObservedComponents.FindAll( item => item != null ).Count == 0;
328
329 if( wasObservedComponentsEmpty == true && isObservedComponentsEmpty == false && m_Target.synchronization == ViewSynchronization.Off )
330 {
331 m_Target.synchronization = ViewSynchronization.UnreliableOnChange;
332 EditorUtility.SetDirty( m_Target );
333 serializedObject.Update();
334 }
335
336 if( wasObservedComponentsEmpty == false && isObservedComponentsEmpty == true )
337 {
338 m_Target.synchronization = ViewSynchronization.Off;
339 EditorUtility.SetDirty( m_Target );
340 serializedObject.Update();
341 }
342
343 }
File name: ReorderableListResources.cs
Copy
168 private static void LoadResourceAssets()
169 {
170 var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;
171 s_Cached = new Texture2D[ skin.Length ];
172
173 for( int i = 0; i < s_Cached.Length; ++i )
174 {
175 // Get image data (PNG) from base64 encoded strings.
176 byte[] imageData = Convert.FromBase64String( skin[ i ] );
177
178 // Gather image size from image data.
179 int texWidth, texHeight;
180 GetImageSize( imageData, out texWidth, out texHeight );
181
182 // Generate texture asset.
183 var tex = new Texture2D( texWidth, texHeight, TextureFormat.ARGB32, false, true );
184 tex.hideFlags = HideFlags.HideAndDontSave;
185 tex.name = "(Generated) ReorderableList:" + i;
186 tex.filterMode = FilterMode.Point;
187 tex.LoadImage( imageData );
188
189 s_Cached[ i ] = tex;
190 }
191
192 s_LightSkin = null;
193 s_DarkSkin = null;
194 }
File name: ReorderableListResources.cs
Copy
202 private static void GetImageSize( byte[] imageData, out int width, out int height )
203 {
204 width = ReadInt( imageData, 3 + 15 );
205 height = ReadInt( imageData, 3 + 15 + 2 + 2 );
206 }
File name: GizmoType.cs
Copy
15 public static void Draw( Vector3 center, GizmoType type, Color color, float size )
16 {
17 Gizmos.color = color;
18
19 switch( type )
20 {
21 case GizmoType.Cube:
22 Gizmos.DrawCube( center, Vector3.one * size );
23 break;
24 case GizmoType.Sphere:
25 Gizmos.DrawSphere( center, size * 0.5f );
26 break;
27 case GizmoType.WireCube:
28 Gizmos.DrawWireCube( center, Vector3.one * size );
29 break;
30 case GizmoType.WireSphere:
31 Gizmos.DrawWireSphere( center, size * 0.5f );
32 break;
33 }
34 }
File name: NetworkingPeer.cs
Copy
3034 public void SetReceivingEnabled(int[] enableGroups, int[] disableGroups)
3035 {
3036 List
3037 List
3038
3039 if (enableGroups != null)
3040 {
3041 for (int index = 0; index < enableGroups.Length; index++)
3042 {
3043 int i = enableGroups[index];
3044 if (i <= 0)
3045 {
3046 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3047 continue;
3048 }
3049 if (!this.allowedReceivingGroups.Contains(i))
3050 {
3051 this.allowedReceivingGroups.Add(i);
3052 enableList.Add((byte)i);
3053 }
3054 }
3055 }
3056 if (disableGroups != null)
3057 {
3058 for (int index = 0; index < disableGroups.Length; index++)
3059 {
3060 int i = disableGroups[index];
3061 if (i <= 0)
3062 {
3063 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled was called with an illegal group number: " + i + ". The group number should be at least 1.");
3064 continue;
3065 }
3066 if (enableList.Contains((byte)i))
3067 {
3068 Debug.LogError("Error: PhotonNetwork.SetReceivingEnabled disableGroups contains a group that is also in the enableGroups: " + i + ".");
3069 continue;
3070 }
3071 if (this.allowedReceivingGroups.Contains(i))
3072 {
3073 this.allowedReceivingGroups.Remove(i);
3074 disableList.Add((byte)i);
3075 }
3076 }
3077 }
3078
3079 this.OpChangeGroups(disableList.Count > 0 ? disableList.ToArray() : null, enableList.Count > 0 ? enableList.ToArray() : null); //Passing a 0 sized array != passing null
3080 }
File name: ShowInfoOfPlayer.cs
Copy
20 void Start()
21 {
22 if (font == null)
23 {
24 #if UNITY_3_5
25 font = (Font)FindObjectsOfTypeIncludingAssets(typeof(Font))[0];
26 #else
27 font = (Font)Resources.FindObjectsOfTypeAll(typeof(Font))[0];
28 #endif
29 Debug.LogWarning("No font defined. Found font: " + font);
30 }
31
32 if (tm == null)
33 {
34 textGo = new GameObject("3d text");
35 //textGo.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
36 textGo.transform.parent = this.gameObject.transform;
37 textGo.transform.localPosition = Vector3.zero;
38
39 MeshRenderer mr = textGo.AddComponent
40 mr.material = font.material;
41 tm = textGo.AddComponent
42 tm.font = font;
43 tm.anchor = TextAnchor.MiddleCenter;
44 if (this.CharacterSize > 0)
45 {
46 tm.characterSize = this.CharacterSize;
47 }
48 }
49 }
File name: VSCode.cs
Copy
72 static string ProgramFilesx86()
73 {
74 if( 8 == IntPtr.Size
75 || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
76 {
77 return Environment.GetEnvironmentVariable("ProgramFiles(x86)");
78 }
79
80 return Environment.GetEnvironmentVariable("ProgramFiles");
81 }
Size 184 lượt xem
Gõ tìm kiếm nhanh...