Custom PropertyDrawer causes Header above it to lose indentation

I think custom property drawers are causing Headers before/above their respective fields to lose their indentations. In the attached screenshots, my Faction field is the one with the custom property drawer.


But if the drawer is below another regular field, the issue does not occur.

My custom property drawer for my Faction field has nothing to do with the HeaderAttribute. How can I fix this?

This is happening for me in 6000.0.33f1 too. Even with a completely empty property drawer that does nothing.

1 Like

Not sure why everything is offset, it should work so it is most likely a bug because of the IMGUIContainer. The inspector uses VisualElements to draw the GUI (by the default), and since you probably haven’t implemented CreatePropertyGUI, Unity automatically creates an IMGUIContainer wrapper for the drawer.

1 Like

Thank you for saying, @Squidcor . I was going crazy thinking I was the only one! ahehe :rofl:

Thank you for your input, @MrCool92 . I’ve tried changing the code to use CreatePropertyGUI instead of OnGUI, and indeed, the issue with the preceding header is gone. My issue now is the indentation of the VisualElement, which I guess is more addressable now than it was before. And it does scratch that visual itch I’ve been having with the header ahehe :grinning_face_with_smiling_eyes:


I guess it’s just kinda weird in a way that I have to relearn and use VisualElements now for CreatePropertyGUI, as opposed to just using OnGUI. Is it actually better to use VisualElements? I’d also need to update my other editor code to make them uniform ahehe

I still hope Unity addresses the previous weird interaction with the header before. Thank you nonetheless, @MrCool92 ! :relieved_face:

Encountered this evidence of IMGUI code rot too. Implementing CreatePropertyGUI fixed it.