예제 #1
0
        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);
            }
        }
예제 #2
0
        public static void ExtractMenuItemWithPath(string menuString, GenericMenu menu, string replacementMenuString, Object[] temporaryContext, int userData, Action <string, Object[], int> onBeforeExecuteCallback, Action <string, Object[], int> onAfterExecuteCallback)
        {
            MenuCallbackObject callbackObject = new MenuCallbackObject();

            callbackObject.menuItemPath            = menuString;
            callbackObject.temporaryContext        = temporaryContext;
            callbackObject.onBeforeExecuteCallback = onBeforeExecuteCallback;
            callbackObject.onAfterExecuteCallback  = onAfterExecuteCallback;
            callbackObject.userData = userData;
            menu.AddItem(new GUIContent(L10n.TrPath(replacementMenuString)), false, MenuCallback, callbackObject);
        }
예제 #3
0
        public static void ExtractMenuItemWithPath(string menuString, GenericMenu menu, string replacementMenuString, UnityEngine.Object[] temporaryContext, int userData, Action <string, UnityEngine.Object[], int> onBeforeExecuteCallback, Action <string, UnityEngine.Object[], int> onAfterExecuteCallback)
        {
            MenuUtils.MenuCallbackObject menuCallbackObject = new MenuUtils.MenuCallbackObject();
            menuCallbackObject.menuItemPath            = menuString;
            menuCallbackObject.temporaryContext        = temporaryContext;
            menuCallbackObject.onBeforeExecuteCallback = onBeforeExecuteCallback;
            menuCallbackObject.onAfterExecuteCallback  = onAfterExecuteCallback;
            menuCallbackObject.userData = userData;
            GUIContent arg_58_1 = new GUIContent(L10n.TrPath(replacementMenuString));
            bool       arg_58_2 = false;

            if (MenuUtils.< > f__mg$cache0 == null)
            {
                MenuUtils.< > f__mg$cache0 = new GenericMenu.MenuFunction2(MenuUtils.MenuCallback);
            }
            menu.AddItem(arg_58_1, arg_58_2, MenuUtils.< > f__mg$cache0, menuCallbackObject);
        }