GetControlRect









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

Featured Snippets


File name: PhotonGUI.cs Copy
172     public static bool AddButton()
173     {
174         Rect controlRect = EditorGUILayout.GetControlRect( false, DefaultAddButtonStyle.fixedHeight - 5 );
175         controlRect.yMin -= 5;
176         controlRect.yMax -= 5;
177
178         Rect addButtonRect = new Rect( controlRect.xMax - DefaultAddButtonStyle.fixedWidth,
179                                        controlRect.yMin,
180                                        DefaultAddButtonStyle.fixedWidth,
181                                        DefaultAddButtonStyle.fixedHeight );
182
183         return GUI.Button( addButtonRect, "", DefaultAddButtonStyle );
184     }
File name: PhotonGUI.cs Copy
229     static Rect DoContainerBody( float height )
230     {
231         Rect controlRect = EditorGUILayout.GetControlRect( false, height );
232         controlRect.yMin -= 3;
233         controlRect.yMax -= 2;
234
235         int controlID = GUIUtility.GetControlID( FocusType.Passive, controlRect );
236
237         if( Event.current.type == EventType.Repaint )
238         {
239             PhotonGUI.DefaultContainerStyle.Draw( controlRect, GUIContent.none, controlID );
240         }
241
242         return controlRect;
243     }
File name: PhotonGUI.cs Copy
262     static Rect DoContainerHeader( string headline, float height, float contentOffset )
263     {
264         GUILayout.Space( 5 );
265         Rect controlRect = EditorGUILayout.GetControlRect( false, height );
266
267         int controlID = GUIUtility.GetControlID( FocusType.Passive, controlRect );
268
269         if( Event.current.type == EventType.Repaint )
270         {
271             PhotonGUI.DefaultTitleStyle.Draw( controlRect, GUIContent.none, controlID );
272
273             Rect labelRect = new Rect( controlRect.xMin + 5 + contentOffset, controlRect.yMin + 5, controlRect.width, controlRect.height );
274             GUI.Label( labelRect, headline, EditorStyles.boldLabel );
275         }
276
277         return controlRect;
278     }

GetControlRect 121 lượt xem

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