Пример #1
0
        void RightClickMenuCallback(object obj)
        {
            ActionMenuElement element = ActionMenuInfo.elementList[(int)obj];
            Rect nodeRect             = new Rect(_mousePos.x, _mousePos.y, kNodeWidth, kNodeHeight);
            Node node = _canvas.Create(nodeRect);

            node.actionName = element.actionName;
        }
Пример #2
0
        void HandleRightClickMenu()
        {
            Event e = Event.current;

            _mousePos = e.mousePosition;

            // 空白区域右键
            bool isCanDo = (e.type == EventType.MouseDown) && (e.button == 1) && IsInBlankArea(_mousePos);

            if (isCanDo)
            {
                GenericMenu menu = new GenericMenu();
                for (int i = 0; i < ActionMenuInfo.elementList.Count; i++)
                {
                    ActionMenuElement element = ActionMenuInfo.elementList[i];
                    menu.AddItem(new GUIContent(element.path), false, RightClickMenuCallback, i);
                }
                menu.ShowAsContext();
                e.Use();
            }
        }