Пример #1
0
        public MiniMap()
        {
            capabilities = Capabilities.Movable;

            m_Dragger = new Dragger {
                clampToParentEdges = true
            };
            this.AddManipulator(m_Dragger);

            anchored = false;

            maxWidth  = 200;
            maxHeight = 200;

            m_Label = new Label("Floating Minimap");

            Add(m_Label);

            RegisterCallback <MouseDownEvent>(OnMouseDown);
            m_Label.RegisterCallback <MouseDownEvent>(EatMouseDown);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
            AddStyleSheetPath("StyleSheets/GraphView/Minimap.uss");

            this.generateVisualContent += OnGenerateVisualContent;
        }
Пример #2
0
        public Blackboard(GraphView associatedGraphView = null)
        {
            var tpl = EditorGUIUtility.Load("UXML/GraphView/Blackboard.uxml") as VisualTreeAsset; AddStyleSheetPath(StyleSheetPath);

            m_MainContainer = tpl.CloneTree();
            m_MainContainer.AddToClassList("mainContainer");

            m_Root = m_MainContainer.Q("content");

            m_HeaderItem = m_MainContainer.Q("header");
            m_HeaderItem.AddToClassList("blackboardHeader");

            m_AddButton = m_MainContainer.Q(name: "addButton") as Button;
            m_AddButton.clickable.clicked += () => {
                if (addItemRequested != null)
                {
                    addItemRequested(this);
                }
            };

            m_TitleLabel       = m_MainContainer.Q <Label>(name: "titleLabel");
            m_SubTitleLabel    = m_MainContainer.Q <Label>(name: "subTitleLabel");
            m_ContentContainer = m_MainContainer.Q(name: "contentContainer");

            hierarchy.Add(m_MainContainer);

            capabilities  |= Capabilities.Movable | Capabilities.Resizable;
            cacheAsBitmap  = true;
            style.overflow = Overflow.Hidden;

            ClearClassList();
            AddToClassList("blackboard");

            m_Dragger = new Dragger {
                clampToParentEdges = true
            };
            this.AddManipulator(m_Dragger);

            scrollable = false;

            hierarchy.Add(new Resizer());

            RegisterCallback <DragUpdatedEvent>(e =>
            {
                e.StopPropagation();
            });

            // event interception to prevent GraphView manipulators from being triggered
            // when working with the blackboard

            // prevent Zoomer manipulator
            RegisterCallback <WheelEvent>(e =>
            {
                e.StopPropagation();
            });

            RegisterCallback <MouseDownEvent>(e =>
            {
                if (e.button == (int)MouseButton.LeftMouse)
                {
                    ClearSelection();
                }
                // prevent ContentDragger manipulator
                e.StopPropagation();
            });

            RegisterCallback <ValidateCommandEvent>(OnValidateCommand);
            RegisterCallback <ExecuteCommandEvent>(OnExecuteCommand);

            m_GraphView = associatedGraphView;
            focusable   = true;
        }