MenuCommand is null when received

EditorUtility.DisplayPopupMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), “MyMenu/”, new MenuCommand(MyObject, MyInt));

[MenuItem("MyMenu/Print MyObject")]
static void PrintMyObject(MenuCommand command)
{
    Debug.Log(command.context.GetType() + " " + command.userData);
}

Hi All,

When I receive the menu function call, PrintMyObject(), the MenuCommand is null. Any Advice?

Thanks,

I found the solution, add ‘CONTEXT’ before your menu item name and it will work.

EditorUtility.DisplayPopupMenu(new Rect(mousePosition.x, mousePosition.y, 0, 0), "CONTEXT/MyMenu/", new MenuCommand(MyObject, MyInt));

[MenuItem("CONTEXT/MyMenu/Print MyObject")]
static void PrintMyObject(MenuCommand command)
{
    Debug.Log(command.context.GetType() + " " + command.userData);
}