Submenu for editor context menu

I’ve got a custom menu item for, say, SpriteRenderers.

    [MenuItem("CONTEXT/SpriteRenderer/My script")]
    private static void ReplaceThisSpriteRenderer() {
        Debug.Log("okee dokee");
        return;
    }

As is, this works properly, with an entry labeled “My script” at the bottom of the menu when right-clicking on a SpriteRenderer in the inspector.

However, I’d like to put it in a subfolder within that context menu, and so I change the MenuItem parameter to
"CONTEXT/SpriteRenderer/Foo/My script"

In this case, when I right-click on a SpriteRenderer, I can see “Foo” at the bottom of the list, but it’s greyed out. Is this by design – to keep these menus flat – or is there a way to have “sub-menus” in these contexts?

Hi @nickfourtimes1 ! I’ve just checked this on Unity 2019.3.0f3 and the “Foo” submenu is not greyed out for me.

What Unity version are you using? could you please check if you are having the same result on a new empty project?

5312940--534102--upload_2019-12-24_13-29-46.png

1 Like