Unity - Scripting API: EditorGUILayout.GetControlRect

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static Rect GetControlRect(params GUILayoutOption[] options);

Declaration

public static Rect GetControlRect(bool hasLabel, params GUILayoutOption[] options);

Declaration

public static Rect GetControlRect(bool hasLabel, float height, params GUILayoutOption[] options);

Declaration

public static Rect GetControlRect(bool hasLabel, float height, GUIStyle style, params GUILayoutOption[] options);

Description

Get a rect for an Editor control.

When creating a new Editor control it is a sound design to implement the actual control without relying on GUILayout and instead have the control take a Rect as parameter, similar to the controls in the EditorGUI class. This ensures the control can also be used in for example a PropertyDrawer, which does not allow GUILayout.

Once a non-layout version of the control is implemented, a layout version can easily be made as well, which simply calls into the non-layout version. In order to get a rect fitting for the control, the GetControlRect function can be used.