3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Have you taken the time to compare the list of methods provided by the editor version versus the in-game version? \$\endgroup\$ Commented Mar 26, 2017 at 14:35
  • \$\begingroup\$ @DMGregory Yes, both have almost the same methods. \$\endgroup\$ Commented Mar 26, 2017 at 14:48

1 Answer 1

5
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.