In Unity 5, I created a ScriptableObject class which adds itself to the Main Menu:

using UnityEngine;
using UnityEditor;

public class MyFancySO : ScriptableObject
{
// Public and [SerializeField] data comes here
}


This code works as expected. When the code is compiled, I can see the new menu being crated and working (a "My Framework" entry appears, and when choosing My Fancy Object), it is created appropriately).

What I am trying to do is to create a method with extended functionality o be added to the menu. So I tried like this:

using UnityEngine;
using UnityEditor;

public class MyFancySO : ScriptableObject
{
// Public and [SerializeField] data comes here

[MenuItem("Assets/Create/My Framework/Objects/My Fancy Object (with more stuff)", menuItem = "My Fancy Object (with more stuff)")]
public static void CreateInstanceWithMoreStuff()
{
// Now I create something, with logic based on what
//   I can read in several files in the unity2d-extras
//   repository.
}
}


And although this code compiles with no errors, I don't see the new menu being created (but just the original menu created by CreateAssetMenu).

What am I missing?

To fix this, remove the code that sets the menuItem variable in the attribute:

[MenuItem("Assets/Create/My Framework/Objects/My Fancy Object (with more stuff)"]
public static void CreateInstanceWithMoreStuff()
{
// Now I create something, with logic based on what
//   I can read in several files in the unity2d-extras
//   repository.
}


For more usage examples, see the Unity (5.6) Documentation for MenuItem

On later versions of Unity (e.g. on 2017.3), your code logs an error:

Ignoring menu item My Fancy Object (with more stuff) because it is in no submenu!


As a side note, I'm not sure why menuItem variable is exposed by Unity. The Unity (5.6) documentation for MenuItem (or later versions) do not mention these variables.

See below for the MenuItem.cs file. You are expected to use the constructors, and not the exposed public variables menuItem, validate, or priority.

public sealed class MenuItem : Attribute
{