Is it matter if I use GUILayout or EditorGUILayout for my custom editor? I need to use one of them in the OnInspectorGUI function.
which one should I use? What are the differences between the two?
Thank you in advance.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityIs it matter if I use GUILayout or EditorGUILayout for my custom editor? I need to use one of them in the OnInspectorGUI function.
which one should I use? What are the differences between the two?
Thank you in advance.
The EditorGUILayout class gives us a number of additional methods for setting up widgets we often want in custom inspectors for configuring GameObjects/Components/etc:
Typed numeric inputs - float, double, int, or long
Siders for integer values, or with user-customizable min & max
"Delayed" versions of text & numeric input fields that don't update their value until the user presses "Enter" or changes focus
Layer mask and Tag selection
Object reference fields (eg. for assigning references to GameObjects, Materials, Textures, other Components, etc.)
2, 3, and 4-component vector widgets
Colour-selection widget
Titlebars and foldout groups for organizing inspectors
So if you want any of these features, the choice is pretty clear.
Even if you don't need these features immediately, it's not a bad idea to use EditorGUILayout in your inspectors anyway, that way they'll be consistent with other code you might write in the future that does need these features, or custom inspectors you import from a third party like Asset Store content.