EditorGUI.MultiFloatField and Editor Inspector window width

Testing the element EditorGUI.MultiFloatField (can be easy used for creating “standard Transform properties” - Position, Rotation etc.). I detected very specific reaction on changing the Editor Inspector width:

  1. if you set the width of Editor Inspector on possible minimum (“Minimum Mode”), that element begin "draw yourself " in 2 lines (the common label on first line and other part of element on second)
    7562167--935626--InspectorWidthMinimum.JPG

  2. If the width of Inspector will be wider (“Common/Normal Mode”), that element begin "draw yourself " in 1 line (the both parts on one line). Note. In these case I had set the “common label” on minimum by special (see below).
    7562167--935632--InspectorWidthNormal.JPG

  3. I tried to set different values of width for GUILayoutUtility.GetRec() / EditorGUIUtility.labelWidth / EditorGUIUtility.fieldWidth

        Rect rect1 = GUILayoutUtility.GetRect(50f, _standartHeight * 2);
        EditorGUIUtility.labelWidth = 10f;
        EditorGUIUtility.fieldWidth = 10f;
        EditorGUI.MultiFloatField(rect1, new GUIContent("EditorGUI.MultiFloatField_1"), new GUIContent[] { new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z") }, arrFloat);

But these values only affect on to draw that element in “Common/Normal Mode” (how the common width will be separated between “Common label” and “Fields”), but doesn’t affect on that element in “Minimum Mode”, and doesn’t affect to the Inspector windows width of when that element are beginning to draw in two lines.

For me now it’s a more an academic question, me interested (I didn’t found these information nowhere):
1. Can be limited the width of Inspector windows which can be set by user?
2. Does exist the parameters which can forbidden to draw a some element in two lines (this element or others elements)?

P.S> :slight_smile:
I decided to study the GUIStyle’s and by random select that element and was upset that the “GUIStule’s parameters didn’t work” as I had been awaited. :rage::face_with_spiral_eyes::sunglasses:
But It was a very specific element and all other works fine

Hi, stumbled upon this by chance. What you need is EditorGUIUtility.wideMode. Just set it to true in your editor/drawer when you want those kinds of fields in one line.

Yes :slight_smile: You are right. I thought this parameter works as getter only.
But FYI it have three different state !!! :slight_smile: (in any case it affect differently on Inspector), EditorGUIUtility.wideMode:

  • = true - always in one line

  • = false - always in two line

  • and not set can be one or two lines related to current Inspector width

Thank you for information.

Remained another question - Can be limited the width of Inspector windows which can be set by user?

Well, it’s never really not set. The Unity editor just sets it before creating each inspector; true if width is bigger than 330, false otherwise. Look: https://github.com/Unity-Technologies/UnityCsReference/blob/61f92bd79ae862c4465d35270f9d1d57befd1761/Modules/UIElementsEditor/Inspector/InspectorElement.cs#L347

That means you can actually read EditorGUIUtility.wideMode to see whether a property drawer of yours should be drawn in one or two lines when you’re trying to follow standard Unity Editor practices.