Editor: Trying to duplicate Unity's Settings Gear icon with dropdown arrow in custom window

Hey all,
I am trying to duplicate the appearance of the standard Unity Settings Icon that appears to the right of each component in the inspector. It is a small gear with an arrow next to it. I would imagine there is a proper built in editor style that matches this but I just can’t seem to find it!

Any tips? I can get pretty close but not xact, and I really want exact to provide a cohesive artist experience.

EditorGUILayout.DropdownButton(EditoGUIUtilty.IconContent("SettingsIcon"), FocusType.Passive, EditorStyles.????);
1 Like

Although this isn’t what you asked, if you do not already know this is how you can add a custom menu to your window

https://leahayes.wordpress.com/2013/04/30/adding-the-little-padlock-button-to-your-editorwindow/

apologies if you already know this

Hi,

You can do it like this:

        GUIStyle iconButtonStyle = GUI.skin.FindStyle("IconButton") ?? EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton");
        GUIContent content = new GUIContent(EditorGUIUtility.Load("icons/d__Popup.png") as Texture2D);
        if (EditorGUILayout.DropdownButton( content, FocusType.Passive, iconButtonStyle))
        {
              
        }

Enjoy :slight_smile:

3 Likes

Thanks! That is perfect. For the dark skin. Do you know the change to make to get a version for the light skin as well? Some artists here use both.

Found it. “icons/_Popup.png”

1 Like

For future reference,

GUIContent popupIcon = EditorGUIUtility.IconContent("_Popup");

Will also work to get the icon, and will automatically adjust for dark theme if necessary.

This doesn’t seem to work for me. It returns the black version on the dark theme when I would expect the grey version. Is there something above this I am missing to enable the auto adjust feature?

Hmmm. Are you sure you’re using the correct icon when making the button? What Unity version are you on? It works for me in Unity 2018 anyway, and I’m using dark mode (also tested light mode).

The full code I used to make the button:

var popupStyle = GUI.skin.FindStyle("IconButton");
var popupIcon = EditorGUIUtility.IconContent("_Popup");
var buttonRect = EditorGUILayout.GetControlRect(false, 20f, GUILayout.MaxWidth(20f));
if (GUI.Button(buttonRect, popupIcon, popupStyle))
{
    //Stuff that happens when you click the button
}

It also worked using a EditorGUILayout.DropdownButton when I tried it.

1 Like

I’m doing much the same, though using GUILayout rather than handle the rects myself. The only real difference is I am getting the IconButton skin from the Inspector skin, but I tried it your way with the same result.

Full dropdowns do look correct per skin. It’s just this icon by itself that I want does not.

Unity 2018.3

GUIStyle iconButtonStyle = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("IconButton");
GUIContent moveGroupButton = EditorGUIUtility.IconContent("_Popup");
// ...
if (GUILayout.Button(moveGroupButton, iconButtonStyle))
{
//
}

Hah nevermind. Error was all mine. Found an errant call that was actually setting the GUI.color to black!

1 Like

Ah, I see. Classic. :smile: