How to prevent EditorGUI.indent from overriding property height (only)

I have a simple property drawer, which draws a single object field, for a Texture object. Both the ObjectField height, and the property height, used by this custom property drawer, are static.
Here are the relevant property drawer lines, from inside OnGUI. (Will post full custom property drawer upon request- its nothing special though)

position.width = 80;
position.height = 80;
Texture2D temp_tex =  (Texture2D) EditorGUI.ObjectField(position, GUIContent.none, tex, typeof(Texture2D), false);

public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        return 100f;

However, when I adjust the indent level, before drawing the property, it appears to affect the HIEGHT of the drawn ObjectField. But I expected “indent” to only affect the width, and x position of the position Rect.

public override void OnInspectorGUI()
        Rect position = EditorGUILayout.GetControlRect(true, 100);
        EditorGUI.PropertyField(position, serializedObject.FindProperty("tester"));

Note that the drawn height of the two ObjectFields, is different. The one that is drawn after increasing the indent, is displayed smaller than the 80 pixels hard-coded (let me repeat that in bold: hard-coded) in the property drawer.

How do I prevent adjustments to the indent level, from affecting height? (but still affect horizontal position, as normal) Do I actually need to reset the Indent Level to zero, apply my own changes to the rect width and x position, then change it back (possible, but a huge pain, and conflicts with advice on bottom of EditorGUI.indentLevel docs page)?

Setting the EditorGUIUtility.hierarchyMode flag to false, didn’t help :

For the sake of posterity, I wanted to share what I sent back from the bug report:

Thanks for submitting! Now that I can
see all of your code in context, I can
confirm this is not in fact a Unity

The problem is that when you use the
various EditorGUI methods, they will
respect the current indent level
within the rect where you draw them.
What happens is that your indent level
inside of your ObjectField rect (the
one with the large preview swatch) is
still 1 at the time it is drawn, and
Unity draws the swatch shorter so that
it maintains the correct aspect ratio.
So in this case, it is actually
correct to manually set the indent
level to 0 before you draw your
ObjectField, and then reset it

Hi! This is a bug with how ObjectField works with Texture assets. Could you please file a report? It should be a super simple, 3-line fix, but I want to make sure we track it. If you post the case number I’d even be happy to take care of it Monday :slight_smile:

That said, in the meantime, you’re right this is the best workaround:

reset the Indent Level to zero, apply
my own changes to the rect width and x
position, then change it back