C# custom inspector "headers"

Hi,
I tried several things (EditorGUILayout.BeginVertical, EditorGUILayout.Foldout, EditorStyles…), and I can’t get the desired effect in my custom inspectors. See screen capture below:
5261033--526298--upload_2019-12-9_9-52-28.png

I would like to get the same “header” style (on “Materials”, “Lighting”, “Probes”…), without the foldout function. I just need that flat background, stretching on full inspector width. How can one do that?

You’ll need to know which GUIStyle is applied to that element, from there you can apply it to your header in a custom inspector. Though I am not entirely sure where you can find that. Maybe you can hack it together by trying an onclick event in the editor that prints out the style and log that to the console, than apply that style to your element?

In case you cant find it, there is a scripting reference for it:

you might be able to get a similar style working like that.

Functionality is from a foldout.
If you want to draw a colored box, then… draw a colored box

Heres the default MeshRenderer materials foldout, and a custom inspector with the normal foldout and a colored box.

To add to the post above, you can get the skin style for foldout using EditorStyles.foldout

I believe that the GUIStyle you’re looking for is called “FoldoutHeader”.

do you know of a way to list up all these guistyles? @SisusCo

They are listed in the docs for a GUISkin, which contains all variants.

You can also just make a GUISkin in your project folder, then inspect it to see the names.

EDIT: Correction: I might have that wrong; I just made a GUISkin and don’t see Foldout Header in there, but I imagine it should be in the docs for GUIStyles or something related.

Its in the docs, but I can’'t get it to work in 2018.3

Or for reference here are all of them:

1 Like

Thanks for your answers! I used EditorStyles.foldoutHeader. The foldout arrow appears, but I’m ok with it.

You may be able to hide it from the style, if you can find the right internal property. Though I wouldnt know what its called or even how to find it in the first place.

Sure. I have my own solution for this, but here is one free tool that can do the same.

Nice, it would be very useful if there was a screenshot of this in the documentation for that specific GUISkin though. But that works for me even though the UI is disgustingly looking xD I might do some tinkering on the GUI, but thats a good starting point to find them.

Agreed, it is quite disgusting indeed, hence the custom solution :stuck_out_tongue:

Also it can be very useful to have the ability to type in some custom text and have it be drawn using the GUIStyle in question. This can help a lot in figuring out whether styles have word-wrapping or not, how they look without any text etc.

This sounds like something that should exist on the asset store, I might get on that :smile:.
Though with black friday I bought Odin, so I dont have all that much need for it.

Edit: That being said, I could see a use-case for this. Not the first time I see this question asked.

2 Likes