public static void ExtractOnlyEnabledMenuItem( ScriptingMenuItem menuItem, GenericMenu menu, string replacementMenuString, Object[] temporaryContext, int userData, Action <string, Object[], ContextMenuOrigin, int> onBeforeExecuteCallback, Action <string, Object[], ContextMenuOrigin, int> onAfterExecuteCallback, ContextMenuOrigin origin, int previousMenuItemPriority = -1) { MenuCallbackObject callbackObject = new MenuCallbackObject(); callbackObject.menuItemPath = menuItem.path; callbackObject.temporaryContext = temporaryContext; callbackObject.onBeforeExecuteCallback = onBeforeExecuteCallback; callbackObject.onAfterExecuteCallback = onAfterExecuteCallback; callbackObject.userData = userData; callbackObject.origin = origin; // logic should match CocoaMenuController.mm and MenuControllerWin.cpp if (menuItem.priority != -1 && menuItem.priority > previousMenuItemPriority + 10) { var separator = Path.GetDirectoryName(replacementMenuString); menu.AddSeparator($"{separator}/"); } if (!menuItem.isSeparator && EditorApplication.ValidateMenuItem(menuItem.path)) { menu.AddItem(new GUIContent(L10n.TrPath(replacementMenuString)), false, MenuCallback, callbackObject); } }