示例#1
0
        protected static void HandleReferencing(IReferencable p_reference, FieldInfo p_fieldInfo, bool p_directExpression = false, Parameter p_parameter = null)
        {
            if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) &&
                Event.current.button == 1 && Event.current.type == EventType.MouseDown)
            {
                RuntimeGenericMenu menu = new RuntimeGenericMenu();

                menu.AddItem(new GUIContent("Copy reference"), false,
                             () =>
                {
                    DashEditorCore.propertyReference = "[$" + p_reference.Id + "." +
                                                       p_fieldInfo.Name + "]";
                });

                if (p_parameter != null && !string.IsNullOrEmpty(DashEditorCore.propertyReference))
                {
                    menu.AddItem(new GUIContent("Paste reference"), false,
                                 () =>
                    {
                        p_parameter.isExpression = true;
                        p_parameter.expression   = DashEditorCore.propertyReference;
                    });
                }

                if (p_directExpression && !string.IsNullOrEmpty(DashEditorCore.propertyReference))
                {
                    menu.AddItem(new GUIContent("Paste reference"), false,
                                 () => { p_fieldInfo.SetValue(p_reference, DashEditorCore.propertyReference); });
                }

                //menu.ShowAsContext();
                GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false, false);
            }
        }
示例#2
0
 void INodeAccess.GetCustomContextMenu(ref RuntimeGenericMenu p_menu)
 {
     if (this is INodeMigratable)
     {
         p_menu.AddItem(new GUIContent("Migrate to "+((INodeMigratable)this).GetMigrateType().Name), false, () => ((INodeMigratable)this).Migrate());
     }
     
     GetCustomContextMenu(ref p_menu);
 }
示例#3
0
        public static GenericMenuPopup Show(RuntimeGenericMenu p_menu, string p_title, Vector2 p_position, int p_width = 200, int p_height = 200, bool p_showSearch = true, bool p_showTooltip = true)
        {
            var popup = new GenericMenuPopup(p_menu, p_title);

            popup.width       = p_width;
            popup.height      = p_height;
            popup.showSearch  = p_showSearch;
            popup.showTooltip = p_showTooltip;
            popup.showTitle   = !string.IsNullOrEmpty(p_title);
            PopupWindow.Show(new Rect(p_position.x, p_position.y, 0, 0), popup);
            return(popup);
        }
示例#4
0
        // TODO Possible type caching?
        public static MenuItemNode GenerateMenuItemNodeTree(RuntimeGenericMenu p_menu)
        {
            MenuItemNode rootNode = new MenuItemNode();

            if (p_menu == null)
            {
                return(rootNode);
            }

            foreach (var menuItem in p_menu.Items)
            {
                string       path        = menuItem.content.text;
                string[]     splitPath   = path.Split('/');
                MenuItemNode currentNode = rootNode;
                for (int i = 0; i < splitPath.Length; i++)
                {
                    currentNode = (i < splitPath.Length - 1)
                        ? currentNode.GetOrCreateNode(splitPath[i])
                        : currentNode.CreateNode(splitPath[i]);
                }

                currentNode.item = menuItem;
                //
                // if (menuItem.separator)
                // {
                //     currentNode.item.separator = true;
                // }
                // else
                // {
                //     currentNode.content = content;
                //     currentNode.func = (GenericMenu.MenuFunction) menuItemType.GetField("func").GetValue(menuItem);
                //     currentNode.func2 = (GenericMenu.MenuFunction2) menuItemType.GetField("func2").GetValue(menuItem);
                //     currentNode.userData = menuItemType.GetField("userData").GetValue(menuItem);
                //     currentNode.on = (bool) menuItemType.GetField("on").GetValue(menuItem);
                // }
            }

            return(rootNode);
        }
示例#5
0
        public static GenericMenuPopup Get(RuntimeGenericMenu p_menu, string p_title)
        {
            var popup = new GenericMenuPopup(p_menu, p_title);

            return(popup);
        }
示例#6
0
 public GenericMenuPopup(RuntimeGenericMenu p_menu, string p_title)
 {
     _title       = p_title;
     showTitle    = !string.IsNullOrWhiteSpace(_title);
     _currentNode = _rootNode = GenerateMenuItemNodeTree(p_menu);
 }
示例#7
0
 protected virtual void GetCustomContextMenu(ref RuntimeGenericMenu p_menu) { }